Send
Close Add comments:
(status displays here)
Got it! This site uses cookies. You consent to this by clicking on "Got it!" or by continuing to use this website.nbsp; Note: This appears on each machine/browser from which this site is accessed.
PHP
1. PHP

PHP is a scripting language that is often used for server side creation of web pages. But PHP can be used in command line mode.
PHP is a popular general-purpose scripting language that is especially suited to web development. Fast, flexible and pragmatic, PHP powers everything from your blog to the most popular websites in the world. From the PHP web site at
https://www.php.net/ .
2. CentOS installation
The CentOS repository has the older PHP 5.4.
The following Linux command(s) install PHP 7.
sudo yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
sudo yum -y install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
yum-config-manager --enable remi-php72
sudo yum -y install php php-mcrypt php-cli php-gd php-curl php-mysql php-ldap php-zip php-fileinfo
This installation information was found at
https://www.tecmint.com/install-php-7-in-centos-7/ on 2019-08-04 and was customized for use here.
3. Interactive mode
The following Linux command(s) enter interactive mode.
php -a
Then type the following commands interactively, pressing
Enter after each command. Press
Ctrl-D to exit interactive mode.
echo(4+3);
The output should be as follows.
7
4. Verify the version
The following Linux command(s) check the installed version of PHP.
php -v
On
2019-08-04 the output was as follows.
PHP 7.2.21 (cli) (built: Jul 30 2019 14:46:08) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
5. Hello world in PHP
The file type of a
PHP program file is
php.
The following Linux command(s) create/edit a hello program in the your home directory using the nano text editor.
nano ~/hello.php
Create the following program text in the editor that will output the text "Hello world"
<?php
print("Hello world\n");
?>
To exit with save, remember to press
Ctrl-X, then "
y" (for yes) and
Enter to exit.
The following Linux command(s) run the program.
$php -f ~/hello.php
The output should be as follows.
Hello world
6. End of page