Forum Moderators: coopster

Message Too Old, No Replies

special symbols like \n , "." .

         

zozzen

8:31 am on Feb 17, 2008 (gmt 0)

10+ Year Member



Hi, I'm quite lost with a lot of special symbols in php.

Sometimes i encountered a "dot" between a string,
like : $a = $b.$c

sometimes i see a strange symbol like \n , \_blank.

While \n is very common and i can figure it what it mean, but I face the problem of finding out the meanings of all these symbols. I've searched the word like ".", "\_blank" in the PHP Manual but nothing shows up.

Could you give me some key words for searching?

Thanks a lot!

phranque

9:15 am on Feb 17, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



escape sequences for special characters [php.net] and string concatenation operator [php.net].
don't know about that "\_blank", though...

zozzen

10:05 am on Feb 17, 2008 (gmt 0)

10+ Year Member



Thanks very much for the key words and the links!

PHP_Chimp

5:06 pm on Feb 17, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Although I guess that you have already read through the manual and worked out that the \ before _black is probably there to escape the _.

It is quite common for people to escape everything that isnt a letter or number. As it is easy to leave a character in a character class that has special meaning and then end up wandering why the regex isnt working. Although it isnt necessary to escape everything if you are not sure then \ anything that isnt alphanumeric.

Although of course the down side of that is \\n will be a literal \ followed by n...so in the long run it is better to know what each of the special characters are. However in the short term, or if you find a regex that isnt behaving as it should, then backslash everything. The most common one to miss is - in the middle of a character class, as that can give some very strange results if you are not looking for a range of character.