php fail to compare two exactly same string -


i've following piece of code

$path = $resource['path']; if (strpos($path, base_url()) == 0) {     $path = fcpath. substr($path, strlen(base_url())); } echo '<pre>'; $x = '/home/gofrendi/public_html/no-cms/themes/ubuntu/assets/default/script.js'; var_dump($path); var_dump($x==$path); var_dump('/home/gofrendi/public_html/no-cms/themes/ubuntu/assets/default/script.js' == $path); echo '</pre>'; 

i'm sure $path consists of /home/gofrendi/public_html/no-cms/themes/ubuntu/assets/default/script.js

and get:

string(82) "/home/gofrendi/public_html/no-cms/themes/ubuntu/assets/default/script.js" bool(false) bool(false) 

seems comparison failed. what's wrong here? php bug or mistake?

edit: gladly show result of code:

echo '<pre>'; $x = '/home/gofrendi/public_html/no-cms/themes/ubuntu/assets/default/script.js'; var_dump($path); var_dump($x); var_dump($x==$x); var_dump($x==$path); var_dump('/home/gofrendi/public_html/no-cms/themes/ubuntu/assets/default/script.js' == $path); echo '</pre>'; 

the result is:

string(82) "/home/gofrendi/public_html/no-cms/themes/ubuntu/assets/default/script.js" string(72) "/home/gofrendi/public_html/no-cms/themes/ubuntu/assets/default/script.js" bool(true) bool(false) bool(false) 

edit again: resolved, str_replace templating system change {{ used_theme }} used theme. used theme 'ubuntu' has 6 character length, while {{ used_theme }} has 10 character length. str_replace performed after code executed. change var_dump result, make such unexpected behavior. everyone's help.

as can see there difference between 2 strings 1 of them of length "82" , other of "72" there invisible (non-printing) characters in string


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -