RE: [PHP] \ Char Problems
| From: | Matthew Ballard | Date: | Wed, 13 Dec 2000 09:11:50 +0000 |
| Subject: | RE: [PHP] \ Char Problems | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-30065@lists.php.net to get a copy of this message | ||
A couple of things:
1. As far as PHP is concerned, if you do '/\\/\\' or "/\\/\\", they are the same thing, and both result in /\/\ in being stored or outputted, it's just because the \ is used as an escape character when storing/outputting text, so when you want an actual \, you have to double it, but it is the same as if there was no escape character, and you used a single \.
2. \'s ALWAYS have to be escaped out when entering strings in PHP, so in the keys for the array, you have to escape out the backslashes there too (not just in the usage of other commands).
3. If you have a ' in '', it has to be escaped out too.
So your array should read (with a * before changes, remove before using):
array ('4' => 'a', '8' => 'b', 'c' => 'c', '3' => 'e', 'f' => 'f', '9' => 'g', '|-|' => 'h', '1' => 'i', 'j' => 'j', '|<' => 'k', '|' => 'l', '/*\\/*\\' => 'm', '|*\\|' => 'n', '0' => 'o', 'p' => 'p', 'q' => 'q', '|2' => 'r', '5' => 's', '7' => 't', 'u' => 'u', '*\\/' => 'v', '*\\/*\\/' => 'w','><' => 'x', '*\'/' => 'y', 'z' => 'z', '+' => 't')
Here it is without the *'s:
array ('4' => 'a', '8' => 'b', 'c' => 'c', '3' => 'e', 'f' => 'f', '9' => 'g', '|-|' => 'h', '1' => 'i', 'j' => 'j', '|<' => 'k', '|' => 'l', '/\\/\\' => 'm', '|\\|' => 'n', '0' => 'o', 'p' => 'p', 'q' => 'q', '|2' => 'r', '5' => 's', '7' => 't', 'u' => 'u', '\\/' => 'v', '\\/\\/' => 'w','><' => 'x', '\'/' => 'y', 'z' => 'z', '+' => 't')
Just don't forget that as far you and PHP are concerned, after the entry of the strings, the \ before the ' and the \ aren't there. Also, if it is enclosed by "", ' don't have to be escaped, but \ still do.
Matthew
At 05:11 PM 12/13/2000 +1000, you wrote:
Sorry for the trouble :) Still not working... I have this array ('4' => 'a', '8' => 'b', 'c' => 'c', '3' => 'e', 'f' => 'f', '9' => 'g', '|-|' => 'h', '1' => 'i', 'j' => 'j', '|<' => 'k', '|' => 'l', '/\/\' => 'm', '|\|' => 'n', '0' => 'o', 'p' => 'p', 'q' => 'q', '|2' => 'r', '5' => 's', '7' => 't', 'u' => 'u', '\/' => 'v', '\/\/' => 'w','><' => 'x', ''/' => 'y', 'z' => 'z', '+' => 't') I get this error: Parse error: parse error, expecting `')'' in c:\inetpub\wwwroot\leetconv.php on line 12 -----Original Message----- From: jeremy brand [mailto:jeremy@nirvani.net] Sent: Wednesday, 13 December 2000 5:07 PM To: Matt Stone Cc: PHP List Subject: RE: [PHP] \ Char Problems double quotes use the back slash to escape characters, that is why you needed to use \\. use single quotes, then use single backslashes. -jeremy Jeremy Brand :: Sr. Software Engineer :: 408-245-9058 :: jeremy@nirvani.net http://www.JeremyBrand.com/Jeremy/Brand/Jeremy_Brand.html for more Get your own Free, Private email at http://www.smackdown.com/ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - At least for the people who send me mail about a new language thatthey're designing, the general advice is: do it to learn about how to write a compiler. --Dennis RitchieOn Wed, 13 Dec 2000, Matt Stone wrote: Date: Wed, 13 Dec 2000 17:00:41 +1000 From: Matt Stone <matt@planetveggie.com> To: jeremy brand <jeremy@nirvani.net> Cc: PHP List <php-general@lists.php.net> Subject: RE: [PHP] \ Char Problems Like so? '/\\/\\' => 'm' it just returns "/\\/\\" -----Original Message----- From: jeremy brand [mailto:jeremy@nirvani.net] Sent: Wednesday, 13 December 2000 4:58 PM To: Matt Stone Cc: PHP List Subject: Re: [PHP] \ Char Problems Try using single quotes instead ('). -jeremy brand Jeremy Brand :: Sr. Software Engineer :: 408-245-9058 :: jeremy@nirvani.net http://www.JeremyBrand.com/Jeremy/Brand/Jeremy_Brand.html for more Get your own Free, Private email at http://www.smackdown.com/ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - At least for the people who send me mail about a new language thatthey're designing, the general advice is: do it to learn about how to write a compiler. --Dennis RitchieOn Wed, 13 Dec 2000, Matt Stone wrote:Date: Wed, 13 Dec 2000 16:55:32 +1000 From: Matt Stone <matt@planetveggie.com> To: PHP List <php-general@lists.php.net> Subject: [PHP] \ Char Problems Hi, I have a code that converts certain chars (l33t chars) into normal text. What I am trying to do is convert all instances of "/\/\" in a string to "M". I have some code that stores all the leet/normal text conversions likeso:"M" => "/\/\", "N" => "|\|" The problems is that if I have it like this then I get a parse errorbecauseof the \ chars. If I change the code like this: "M" => "/\\/\\", "N" => "|\\|" Then the conversion is not made because it will not find "/\\/\\" in the string, only "/\/\". Any ideas? Thanks, Matt Stone _______________________________ This email may contain confidential and/or privileged information forthesole use of the intended recipient. Any review or distribution by othersisstrictly prohibited. If you have received this email in error, please contact the sender and delete all copies. Opinions, conclusions or other information expressed or contained in this email are not given orendorsedby the sender unless otherwise affirmed independently by the sender. _________________________________ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net-- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net