PHP First Program is a simple hello world program that helps you to learn how to write your first program and code in PHP.
Php file extension is .php
Note: Always save your php file or new file with extension of .php
Code | |||||||
---|---|---|---|---|---|---|---|
<?php echo "Hello World"; ?> |
PHP program can be run by xamp or wamp server.
Step1 - Start your xamp or wamp server.
Step2 - Go to your browser and type url https://localhost/php/first-program.php
.
Output | |||||||
---|---|---|---|---|---|---|---|
Hello World |
Php Support both statement print
,echo
to print or display message.
Below Example show you how to use print
syntax to print hello world
Code | |||||||
---|---|---|---|---|---|---|---|
<?php print "Hello World"; ?> |
Type Url - https://localhost/php/print-hello-world.php
1.Following is the same code as above but different syntax, value for practice purpose.
In Below code we are using echo
sytax to print value and value is hello php.
Code 1 | |||||||
---|---|---|---|---|---|---|---|
<?php echo "Hello PHP"; ?> |
Type Url - https://localhost/php/echo-hello.php
2.Following is the same code as above but different syntax, value for practice purpose.
In Below code we are using echo
syntax to print value and value is hello your name.
Code 2 | |||||||
---|---|---|---|---|---|---|---|
<?php echo "Hello Your Name"; ?> |
Type Url - https://localhost/php/echo-hello-name.php
3.Following is the same code as above but different syntax, value for practice purpose.
In Below code we are using print
syntax to print value and value is hello php.
Code 3 | |||||||
---|---|---|---|---|---|---|---|
<?php print "Hello PHP"; ?> |
https://localhost/php/print-hello.php
4.Following is the same code as above but different syntax, value for practice purpose.
In Below code we are using print
syntax to print value and value is hello your name.
Code 4 | |||||||
---|---|---|---|---|---|---|---|
<?php print "Hello Your Name"; ?> |
Type Url - https://localhost/php/print-hello-name.php
echo "My First Program";
echo "My First PHP Program";
print "My First Program";
print "My First PHP Program";