Menu icon Foundation
setting php variable using visibility class

Can anyone tell me why this is not working?

<?php $max=3; ?>

 <span class="show-for-medium-only"><?php $max=4;?></span>

 

I'm setting $max to 3. Then if the screen size is medium it should change the value to 4.

But the value goes to 4 whatever the screen size. Yet if I add some text to the line :-

 <span class="show-for-medium-only"><?php $max=4;?>MEDIUM</span>

$max is still always 4 and yet MEDIUM is correctly only printed on medium size screens?

I'm baffled

 

PHPvisibility classes

Can anyone tell me why this is not working?

<?php $max=3; ?>

 <span class="show-for-medium-only"><?php $max=4;?></span>

 

I'm setting $max to 3. Then if the screen size is medium it should change the value to 4.

But the value goes to 4 whatever the screen size. Yet if I add some text to the line :-

 <span class="show-for-medium-only"><?php $max=4;?>MEDIUM</span>

$max is still always 4 and yet MEDIUM is correctly only printed on medium size screens?

I'm baffled

 

Rafi Benkual over 2 years ago

Not sure how the CSS would affect this PHP call. The reason is that visibility classes happen client side and php is happening server side, so they will not affect each other.

Graham Dunsby over 2 years ago

Ah of course - stupid of me

So I should be able to get round it using Javascript instead