strpos question



I am trying to right an if statment using strpos to determine if the
string exists in the variable, however I seem to be getting the wrong
effect. Here is my script.

<?php
$dn = "ABC-DEF";

$pos = strpos( $dn, "ABC-DEF" );
if ( $pos != FALSE )
{
echo 'variable contains value';
}
else
{
echo ' variable does not contain value' ;
}
?>

It keeps returning does not contain value. I am kinda new to strpos,
any suggestions?

.



Relevant Pages

  • Re: Regular expression newbie question
    ... I know I can do it with strpos, but I need to use regular expression. ... > echo "http:// not found in string"; ...
    (alt.php)
  • Re: RES: [PHP] string
    ... Since 'John' is the first thing in the string strpos will return 0 causing the condition to evaluate to false. ... As per the documentation for strpos you should compare the value *and type* of the variable returned by strpos against false to check for non-existance. ... I want to verify if $name contains "john", if yes echo "found"; ... PHP General Mailing List To unsubscribe, ...
    (php.general)
  • Re: [PHP] strpos error (Im missing something obvious)
    ... echo "yes"; ... strpos returns an integer representing the position of the needle in the haystack. ...
    (php.general)
  • Re: Binary-safe?
    ... it operates on the data as a raw byte stream. ... needs to know something about what is represented by the raw byte ... So, in terms of bytes, strpos would be passed in 0x00 0x16 as the first ... parameter was an empty string. ...
    (alt.php)
  • Re: php get part of url content
    ... does not use google or hang about on nntp. ...  I tried strpos but it doesn't work. ... advance to a point just after the string: ... group would whip out some convoluted regexp to do it, ...
    (comp.lang.php)