View Full Version : [SOLVED] php what if string to search is '$b' text search?
sdowney717
February 12th, 2011, 03:26 PM
like do this
$pos = strpos($fileline, "$b");
will that work since the editor is showing $b as a variable?
what I want is for strpos to look for $b itself as text.
do you backslash escape it?
Vaphell
February 12th, 2011, 04:00 PM
not that i know anything about php but if it's anything like bash with strings try single quotes '$b'
http://php.net/manual/en/language.types.string.php
according to that page ' ' is literal string and " " is string with variable expansion.
of course escaping works too.
s.fox
February 13th, 2011, 03:05 PM
Hello,
I would use single quotes as it will be treated as a literal string.
-s.fox
xtremethegreat1
February 13th, 2011, 03:16 PM
You wanna use single quotes. Double quotes will just show the value of $b in quotes.
Example:
$b = 'Hello'
echo $b;
Output:
Hello
echo '$b';
Output:
$b
echo "$b";
Output:
Hello
Powered by vBulletin® Version 4.2.2 Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.