Page 1 of 1
Checking if a ? is in a variable...
Posted: Tue Jun 27, 2006 1:20 am
by Mr Tech
I tried to use this code to check and see if a question mark (?) is in a $variable...
Code: Select all
if (!preg_match("/?/", $back_page)) {
However, it doesn't work... What can I do to make it work?
Posted: Tue Jun 27, 2006 1:22 am
by RobertGonzalez
Posted: Tue Jun 27, 2006 1:42 am
by Mr Tech
Thanks!
Posted: Tue Jun 27, 2006 3:09 am
by Christopher
? is a regexp character. Try:
Code: Select all
if (!preg_match("/[\?]/", $back_page)) {
Posted: Tue Jun 27, 2006 9:58 am
by RobertGonzalez
From
the PHP Manual on preg_match:
The PHP Manual: preg_match page wrote:Tip: Do not use preg_match() if you only want to check if one string is contained in another string. Use strpos() or strstr() instead as they will be faster.
Posted: Tue Jun 27, 2006 12:10 pm
by sweatje
arborint wrote:? is a regexp character. Try:
Code: Select all
if (!preg_match("/[\?]/", $back_page)) {
Code: Select all
if (!preg_match('/'.preg_quote('?','/').'/', $back_page)) {
