can any help me regarding how PHP handles strings. Is there any diffrence when we use a double quotes or single quotes in any program. I tried this small program but get the same output in all the cases. $around='around'; echo "What goes ". $around .",comes ". $around ." <br/>"; echo 'What goes '. $around .',comes '. $around .'<br/>'; $around="around"; echo "What goes ". $around .",comes ". $around ." <br/>"; echo 'What goes '. $around .',comes '. $around .'<br/>';
No there isn't. PHP using weak typing, which means you do not have to define a variable type. However, it does have a presedence order so declaring; $myvar = "2"; //This will be counted internally as a char* array or std::string is different from this $myvar = 2; //This will be counted internally as an interger and this $myvar = 2.0; //This will be counted as a float (or long on some systems) internally. This however does not matter a great deal for your basic n00bie. You will only ever need to learn this stuff if you NEED to know it for PHP. I suggest a quick Google Search in variable declaration and strong and weak typing. Also search for something called "Casting" (Not used in PHP but will help you to understand why you paid so much for that shiny new Intel processor). Hope this helps! Andrew
php can substitute variables inside double quotes, try : echo "what goes $around, comes around <br>" ;
mallor thats a very depreciated style. a PHP5/XHTML compliant form would be; echo("What goes $around, comes around <br />"); But yes you can do that. You only ever need to do "something" . $like . "this" when you do "something" . nl2br($like) . "this" if you understand me.
yes it seems you are using variables like javascript as php does not need the spacing and dots just use the variable once define $around
You only ever need to do "something" . $like . "this" when you do "something" . nl2br($like) . "this" if you understand me. did not get the last line..... pls explain
@ Srisen 2: I do not know javascript. Was just trying my hand on concatenation. But java script is the next one in my line "To DO"
Double quotes automatically parse ur variable. For instance, $var='there'; //Case 1 Echo "Hello $var, how are you?" ; //Case 2 Echo "Hello"." ".$var.", how are you?"; Both cases 1 and 2 will outputs exactly the same result but what made all the differences is the syntax of case 2 which appears alot quite complicated. A good programming is writting out the code neatly, which will eventually prevent any errors from occuring in withing your code. nl2br() in php is equivalent to <br/> in html.
@spaceman12: Thanks for telling about nl2br(). Was just searching for it. Suggest some good source for learning PHP.
nl2br() is not the PHP equiv to <br /> in XHTML (not HTML). It is a function that will convert all C style \n keywords into XHTML compliant <br /> tags. Also a brilliant book for beginners is on amazon, "PHP5 in easy steps". It's what I used many many moons ago but its very very good at teaching all the core components, leaving you ready to tackle PHP head on. The only thing you should need afterwards is the knowledge of specific PHP functions which can easily be learnt straight from php.net Andrew
as for me, http://www.w3schools.com is where i first started off with php.(now m very and highly advanced,) All the explaination and tutorial there are just too simple and unique. When you have become a lil bit more advanced, php.net, the online manual documentation for php, is where u will most probably be wanting to look up for various functions and their usage related to php.
try looking at some basic examples on php.net youll get it variable are $variablename = "variable ifnormation"; and echo "$variable"; to display the variable and just $variable anywhere to use the variable