
Originally Posted by
sherlyk
Semicolon at end of print statement missing.
print function same as echo, but use echo, forget print. echo is more popular, also there are more ways to print, some complicated, but is not required for most programming project.
Code:
print ("$name is $age years old. ")
Proper usage
Code:
echo $name . ' is ' . $age . ' years old. ';
Or
Code:
echo "$name is $age years old. ";
Advantage of using single quote is PHP know it is just string, so it will be faster. If using double quote, PHP compilter need to look for variable inside the string and convert it to its value, that need more processing time (not much, still do that way as a convention whenever possible).
Bookmarks