PHP First Program

How To Install PHP Wamp Server Step by Step Previous Next PHP Comments


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

Filename: php / first-program.php


Code
<?php
echo "Hello World";
?>

Running Step.


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 Print


Php Support both statement print,echo to print or display message.

Below Example show you how to use print syntax to print hello world

Filename: php / print-hello-world.php


Code
<?php
print "Hello World";
?>

Running Step.


Type Url - https://localhost/php/print-hello-world.php

More Code Examples


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.

Filename: php / echo-hello.php


Code 1
<?php
echo "Hello PHP";
?>

Running Step.


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.

Filename: php / echo-hello-name.php


Code 2
<?php
echo "Hello Your Name";
?>

Running Step.


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.

Filename: php / print-hello.php


Code 3
<?php
print "Hello PHP";
?>

Running Step.


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.

Filename: php / print-hello-name.php


Code 4
<?php
print "Hello Your Name";
?>

Running Step.


Type Url - https://localhost/php/print-hello-name.php

More PHP value to echo


echo "My First Program";

echo "My First PHP Program";

More PHP value to print.


print "My First Program";

print "My First PHP Program";


Tags: PHP


Was this helpful ?

Related Code


Popular Code

Latest Code