views:

134

answers:

2

I have a variable that I am calculating the length of and in all browsers except FF (IE, Chrome, Safari) the value is 0.

However in FF, the value is 65 (see screenshot - value beneath photograph)

screenshot

Link to site page

I have cleared my cache with cc cleaner and using the clear cache option in FF itself.

The code I am using wordpress and the code to display the strlen value is:-

<? $liurl =  get('ksl_linkedin'); 
$liurl = trim($liurl," ");
echo strlen($liurl);
?>

Any help would be greatly appreciated.

Thanks

Jonathan

+3  A: 

The result of a PHP function has nothing to do with the browser - it's calculated before the data gets to the browser. (for what it's worth, I get "0" with Firefox as well.)

The only scenario where the browser could play a role is when the data is input by the user some way, or enters the script through a GET or POST variable.

My suspicion is that your get() function returns different values, maybe depending on whether you're logged into Wordpress or not.

What does the function do?

Can you show us an example link?

Pekka
Thanks Pekka - you nailed it - for some bizarre reason it shows different values dependent on whether I am logged in as admin or not - very strange. Bascially the get function simply retrieves a value from a field in the database which is empty for this user.
Jonathan Lyon
That is probably a rights problem and could well be by design. I can't find any documentation about get() in the codex, but that would definitiely be the path to investigate further and find out.
Pekka
I think it is a bug to be honest. I am using a plugin called flutter that allows you store extra data for any given post and this function just lets you reference the field. What is strange is that if you echo it out when logged in - it is blank (65 spaces) and 0 when logged out so a bug I think. - Thanks anyway
Jonathan Lyon
odd. It's blank when you look in the source, too? 65 characters of blank? Can you do a `print_r()` on it?
Pekka
it shows string(64) " " when logged in and string(0) "" when logged out using var_dump
Jonathan Lyon
Strange. All right, that really sounds like a bug.
Pekka
A: 

I bet it has nothing to do with Firefox. PHP is executed at the server side, so it is not interacting with the browser. See also How does PHP work.

What is get() doing? Probably this the source of the problem.

Btw it shows 0 with Firefox 3.6. on a Mac.

Felix Kling