-
PHP Starter problems
After a period of use of various CMS's, I have begun to recognize the strength of being able to at least basic PHP. I have begun to look at some code that I threw up on my hosting to see what happens.
Now, however, I encountered the patrol, and I can not understand what is wrong. The code is extremely small and simple, like my PHP knowledge with other words.
The following code generates a "Parse error: syntax error, unexpected T_STRING in *******/ test.php on line 6".
PHP Code:
<?php
$strang1 = This is;
$strang2 = string;
$strang3 = $strang1.$strang2;
/* This will print: "This is a string"*/
echo $strang3;
?>
What is wrong?
-
Re: PHP Starter problems
$strang1 = This is;
$strang2 = string;
You do not have " around the text?
-
Re: PHP Starter problems
<? php
$strang1 = "This is";
$strang2 = "a string";
$strang3 = $strang1.$strang2;
/* This will print: "This is a string" */
echo $strang3;
?>
-
Re: PHP Starter problems
Of course. Rookie mistake, so the whistle on that ;)
Thanks for the quick help!
-
Re: PHP Starter problems
However, one should be mindful of the difference between using:
<?PHP
$name = 'Erik';
// With easy fnuttar evaluated and given no value from $name, but printed as just $name
echo('Hello $name how are you?');
// Dock double fnuttar
echo("Hello $name how are you?");
// To print Hello Erik how are you? out.
?>
In other words. Have you no use to evaluate the variables in a string, so use simple fnuttar.
Page generated in 1,713,537,093.56931 seconds with 10 queries