Welcome to PHPMule.com
A blog site which I am posting to during my learning of the popular programming language PHP. Feel free to leave comments!
-
PHP Variables
In PHP, variables are used for storing a value, whether it’s a text string or numbers.
A variable in PHP has to start with the ‘$’ sign followed by whatever you want to call the variable and then the variables value which would look something like this:
$dvd = “Casino Royale”
a number can also be stored in a variable:
$ageoffilm = 3
So what would happen if we made a PHP script using these variables?
<?php
$dvd = “Casino Royale”;
$ageoffilm = 3;
?>
<html>
<head><title>Movies</title></head>
<body>
<?php
echo “Best bond film: ” . $dvd . “<br />”;
echo “How old is the film: ” . $ageoffilm . “<br />”;
?>
</body>
</html>
This would output:
Best bond film: Casino Royale
How old is the film: 3By the way you may notice the cotcatination operator which is basically just a period “.”
You can use this operator to add strings together as shown in the example above.
(Post created on Sunday, April 5th 09 at 23:45)
Leave a reply
-
Archives
Recent Articles
- PHP - Rounding Off Numbers
- PHP - Single vs Double Quotation Marks
- PHP - Loading Files Into Your PHP Script By Using require() and include()
- PHP - Replacing Strings With Other Strings
- PHP - Finding Strings Within Strings
- PHP - Using strlen() To Test String Length
- PHP - Using The explode() Function
- PHP - Changing The String Case
- PHP - The nl2br() Function
- PHP - Trimming Strings
Links
Categories
- PHP (22)
- Uncategorized (1)


