Hello World - Printing and Using PHP Variables

Rate: 1 Star Rate: 2 Stars Rate: 3 Stars Rate: 4 Stars Rate: 5 Stars

Love it / Hate it

Comments + Likes

Hello World - Printing and Using PHP Variables

Programming / PHP

Hello World - Printing and Using PHP Variables

How to print using strings, variables and integers
Hello World - Printing and Using PHP Variables was posted by listylister and has had 284 view(s) with an overall rating of 5
Chris's Profile Picture

Posted by listylister

Their Website http://www.phptutor...

This Tutorial has had 284 Views

PHP is much like any other programming languages in that it uses the same concepts but in different ways.
It can be considered one of the easier programming languages to learn because it does a lot for you. However, one must still make sure that they are performing the task in the most effective way.
Print Command

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


This will print the text Hello World onto the webpage as long as the page is saved with file extension .php and PHP 4 / 5 is installed on the server.
Print using Variables

<?php
$text 
"Hello World";
print 
$text;
?>;


This demonstrates how variables work - they are not 'typed' like many other languages and most of the time are stored as strings. However, in some cases you may need to use integers and they can be defined as follows:
Print using Numeric Variables

<?php
$number 
2;
print 
$number;
?>;


This sometimes needs to be done if you are performing calculations.

created on 17/12/2009 @ 00:16, last updated on 23/06/2010 @ 21:15
aProject.info Twitter RSS

  Copyright PHPTutorials.co © 2009 - 2010