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.
Copyright PHPTutorials.co © 2009 - 2010