lordvader Posted June 18, 2006 Share Posted June 18, 2006 I'm learning php bit by bit, as my needs arise. I've come across $disp, but am unsure of a few things:What is the difference with$disp .=and$disp =Also, in relation to $disp, what is "\t and \n" and what are the proper uses?Or you could just tell me what category in php that stuff falls under, and I'll look it up myselfThanks Quote Link to comment https://forums.phpfreaks.com/topic/12273-noob-questions-about-using-disp/ Share on other sites More sharing options...
Fyorl Posted June 18, 2006 Share Posted June 18, 2006 $disp is a variable. It stores pretty much anything you put in it. A variable can be anything beginning with a letter or underscore followed by any number of other letters, numbers or underscores. $disp isn't special in any way the same as $foo and $bar aren't (even if you see them a lot).$disp =will put a value in the variable like:$disp = 'a string';then if you were to do$disp .= ' is cool';and thenecho $disp;you would see: a string is coolYou can also put numbers in ($disp = 2456729). The two main methods of storing strings is with single quotes and double quotes. Single quotes are very literal so $disp = '\n' would print just that but $disp = "\n"; would be seen as a newline character.That's a basic overview, there's plenty of documentation about. Quote Link to comment https://forums.phpfreaks.com/topic/12273-noob-questions-about-using-disp/#findComment-46868 Share on other sites More sharing options...
lordvader Posted June 18, 2006 Author Share Posted June 18, 2006 And that's totally enough!Thanks Fyorl Quote Link to comment https://forums.phpfreaks.com/topic/12273-noob-questions-about-using-disp/#findComment-46879 Share on other sites More sharing options...
neylitalo Posted June 18, 2006 Share Posted June 18, 2006 PHP has several little shortcuts built in (as do most programming languages); I'll put the shortcut on top, and the long version on the bottom.[code]$a .= $b;$a = $a + $b//strings only![/code]And the rest are for numbers:[code]$a += $b;$a = $a + $b;[/code][code]$a -= $b;$a = $a - $b;[/code][code]$a *= $b;$a = $a * $b;[/code][code]$a /= $b;$a = $a / $b;[/code] Quote Link to comment https://forums.phpfreaks.com/topic/12273-noob-questions-about-using-disp/#findComment-46894 Share on other sites More sharing options...
Fyorl Posted June 18, 2006 Share Posted June 18, 2006 [!--quoteo(post=385211:date=Jun 17 2006, 09:42 PM:name=neylitalo)--][div class=\'quotetop\']QUOTE(neylitalo @ Jun 17 2006, 09:42 PM) [snapback]385211[/snapback][/div][div class=\'quotemain\'][!--quotec--]PHP has several little shortcuts built in (as do most programming languages); I'll put the shortcut on top, and the long version on the bottom.[code]$a .= $b;$a = $a + $b//strings only![/code]And the rest are for numbers:[code]$a += $b;$a = $a + $b;[/code][code]$a -= $b;$a = $a - $b;[/code][code]$a *= $b;$a = $a * $b;[/code][code]$a /= $b;$a = $a / $b;[/code][/quote][code]$a .= $b;// Is actually a shortcut for$a = $a . $b;[/code]Javascript uses + to concatenate strings, PHP uses '.'. Using the + operator on strings is possible in PHP as PHP will turn '15' into 15 for the purpose of the calculation but if it is not a number, the ASCII key code gets used I seem to recall. Quote Link to comment https://forums.phpfreaks.com/topic/12273-noob-questions-about-using-disp/#findComment-46902 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.