Note: In this site, I am using XAMPP server and in windows operating system and installed XAMPP in C drive, so make sure you install XAMPP server.
- The popular editor used to edit a PHP code
Step by step run PHP program is given below
- Go into HTDOCS folder and create your folder name like "first_program", and into folder create a file give a name "welcome.php"
- "welcome.php" file open in any editor you like.
- Start the XAMPP server and start Apache and MySQL.
- Below code write into "welcome.php".
- PHP script that uses a built-in PHP function "echo" to output.
<h1>My first PHP page</h1>
echo "Hello World! ";
- See output in web browser like Chrome, Microsoft Edge, Internet Explorer, Firefox, etc.
- seacrch localhost/your_folder_name = http://localhost/first_program/welcome.php.
In PHP, keywords (e.g. if,
else, while, echo, etc.),
classes, functions, and user-defined functions are not case-sensitive.
- In the example below, all three echo statements below are equal
ECHO "Hello World!<br>";
echo "Hello World!<br>";
EcHo "Hello World!<br>";
Note: In PHP, all variable names are case-sensitive!
Look at the example below; only the first statement will display the value of the
$color variable! This is because $color,
$COLOR, and $coLOR are treated as three different variables:
$color = "red";
echo "My car is " . $color . "<br>";
echo "My house is " . $COLOR . "<br>";
echo "My bike is " . $coLOR . "<br>";
My car color is red
Notice: Undefined variable: COLOR in C:\xampp\htdocs\example\p6.php on line 8
My house color is
Notice: Undefined variable: coLOR in C:\xampp\htdocs\example\p6.php on line 9
My bike color is
Note: In above example,my house is and my bike is name was not show because "Undefined variable : $COLOR, $coLOR"