unexpected character in input!?(PHP)

Programming, for all ages and all languages.
Post Reply
earlz
Member
Member
Posts: 1546
Joined: Thu Jul 07, 2005 11:00 pm
Contact:

unexpected character in input!?(PHP)

Post by earlz »

Ok, I am really just wanting to knowexactly why PHP gives a warning on somethign liek this...
$bah='\' ';
(those are all single quotes)

I could just disable the warning, but that just doesn't seem right...


edit:
ok...now know how to probably fix it, but it doesn't really matter....never allow people to inject code...even if it is into quoteation marks...
User avatar
os64dev
Member
Member
Posts: 553
Joined: Sat Jan 27, 2007 3:21 pm
Location: Best, Netherlands

Post by os64dev »

no, clue about warning but "'" works in php.
Author of COBOS
TomB
Posts: 8
Joined: Thu Dec 08, 2005 12:00 am

Post by TomB »

Escape characters do not work in single quotes, you must use double quotes for escaped characters.
SpooK
Member
Member
Posts: 260
Joined: Sun Jun 18, 2006 7:21 pm

Post by SpooK »

TomB wrote:Escape characters do not work in single quotes, you must use double quotes for escaped characters.
Not true, at least in PHP... and doubly for Regular Expressions.
User avatar
Zacariaz
Member
Member
Posts: 1069
Joined: Tue May 22, 2007 2:36 pm
Contact:

Post by Zacariaz »

SpooK wrote:
TomB wrote:Escape characters do not work in single quotes, you must use double quotes for escaped characters.
Not true, at least in PHP... and doubly for Regular Expressions.
It is indeed true, in some version/builds at least. also i have experience "echo" not being able to display escape charecters at all, but having no problems with "print".
This was supposed to be a cool signature...
SpooK
Member
Member
Posts: 260
Joined: Sun Jun 18, 2006 7:21 pm

Post by SpooK »

Zacariaz wrote:
SpooK wrote:
TomB wrote:Escape characters do not work in single quotes, you must use double quotes for escaped characters.
Not true, at least in PHP... and doubly for Regular Expressions.
It is indeed true, in some version/builds at least. also i have experience "echo" not being able to display escape charecters at all, but having no problems with "print".
You are probably right :!:

I remembered that whenever I install PHP, I ensure that Magic Quotes are disabled in the PHP initialization file. Something I usually and happily forget there-on after :P

Look in to this (or simply disable at script runtime) if any of you are having awkward escape character issues :idea:
Post Reply