First PHP script Every language has it… First PHP script the basic “Hello, World!” script. It is a simple script that only displays the words“Hello, World!”. Over the years this has become the traditional phrase to use when writing your first program. |
According to Wikipedia, it’s mainstream usage spawned from an internal memorandum in 1974 that became incorporated into the book The C Programming Language. It’s actual first known usage was inKernighan’s 1972 A Tutorial Introduction to the Language B. From this it has grown into somewhat of a tradition in the programming world. |
So how do I do it in PHP? Well the two simplest ways are using Print or Echo. |
Syntax: |
echo (“val”); |
<?php echo "<h1>Welcome to Ebiz Education!</h1>" ?> |
Here, as we read that HTML Embeds in the php code,that’s why <h1>and </h1> is used here in the php script.echo() is not actually a function (it is a language construct) so you are not required to use parentheses with it ( whereas print is a function,it returns a value, it does not take multiple parameters). If you’re running Apache, create a folder named test within the htdocs directory and save the file as hello.php in the test directory. |
Now, open the page in the browser to see the output: |
http://localhost/test/hello.php |
if your apache installation is working fine, you should have the following output: |
Assignment |
1) Write a PHP script to display following eBIZ Education Team Welcomes You PHP Rocks
2) Write a PHP script to print your Name, Age and Address |