Hi,
I am seeing a strange behaviour regarding strpos function
using php5.0.5/apache2
In the following code
if i call this function from the main program and pass the $header value it doesn't do anything falls to the default else condition
however if I define $header inside the function that it works and gives the results as desired.
Ex.
Appreciate any help in this regards.
Thanks,
I am seeing a strange behaviour regarding strpos function
using php5.0.5/apache2
In the following code
Code:
function Clean_header_from($header)
{
if(strpos($header,"<") === 0)
{
$clean_head=str_replace("<","",$header);
$clean_head=str_replace(">","",$clean_head);
}
elseif(strpos($header,"<") > 0)
{
$name_pos=strpos($header,"<");
$name=substr($header,0,$name_pos);
$email_pos=strlen($name)+1;
$email=substr($header,$email_pos);
$email=str_replace("<","",$email);
$email=str_replace(">","",$email);
//$email=str_replace("From:", "", $email);
$name=str_replace("\"","",$name);
$clean_head=$email;
//.";".$name;
}
else
$clean_head=$header.";";
return $clean_head;
}
however if I define $header inside the function that it works and gives the results as desired.
Ex.
Code:
if I call this function like and pass it a value
$x = new class();->instantiating the class inside which the function is defined
$new = $x->Clean_header_from($header);=>where $header = '"name" <user@domain.tld'
nothing happens and falls to the default else condition
However if I define $header inside the function as $header = '"name" <user@domain.tld>'
I get the name and user@domain.tld values.
Thanks,