Abit basic but its left me abit confused, how do I search a string to check if it contains a question mark, e.g. the following is not working and brings incorrect results:
if (ereg('?',$_SERVER[REQUEST_URI])) { }
Abit basic but its left me abit confused, how do I search a string to check if it contains a question mark, e.g. the following is not working and brings incorrect results:
if (ereg('?',$_SERVER[REQUEST_URI])) { }
Use [man]strpos/man.
sorted thanks:
if (strpos($_SERVER[REQUEST_URI],"?")) { echo 'y'; } else { echo 'n'; }
That's not quite right, I think you missed out a small (but potentially important) point raised in the PHP manual. strpos() will return 0 if the search string is at position 0, and this will be interpreted as false, unless you do something like:
if (strpos($_SERVER['REQUEST_URI'], "?") !== false) {
echo 'y';
} else {
echo 'n';
}