Friday, 28 August 2009

Php Tutorial Part 3

Variables Continue:
You can have very useful functions with variables.
For example:
$var1 = "Welcome";
$var2 = " to my website";
echo $var1 . $var2;
?>
The above code will output in one line Welcome to my website (They words are not connected why? Because in the $var2 the beginning starts with space if it was not a space character there the programmer should do this echo $var1 . " " . $var2; This will print an extra space between the two characters.
While i was designing a php website someone ask how do i find out what is the length of a variable in phpThe answer is simple and is provided for you in php with the function strlen() The use is:
$var1 = "Welcome to Cyprus have a Nice day";
//call a function to show how many characters are in a varialbe
echo strlen($var1);
//The output should be: 33
?>
In php they are many functions that will help you with your string variables we will refer to them later in the tutorials

No comments:

Post a Comment

Reset numbering for Screenshots Win+PrtSc

I was using today the screen shot functionality of Windows 8.1 Win Key + PrtSc How to reset the numbering?