PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
<?php
if($ie=="ie")
{ //I end the php to do some javascript
?>
<script type="javascript">
if (screen.width==800 || screen.height==600)
{
<?php $ie="small"; ?>
}
</script>
<?php
}
....
....
?>
what am i doing wrong???
if i am right then if the javascript IF statement is wrong then the $ie will never be "small". But when i try it , it is always "small"
You can't mix PHP with JavaScript like that. PHP runs on the server before the page is sent to the browser. JavaScript runs once the page has been sent to the browser.
If you want to get a variable from JS to PHP you will need to send it via GET (as part of a url) or POST (as part of a form).
i already coded a css switcher in php and it depends on which browser the user uses...So i must either recode the switcher in javascript or find a shorter way...
I would always normally suggest to people to use PHP, but for this job I would recommened JS. The main reason being you won't have to bounce people around to different pages just to sort out the CSS.
Here's my JS I use for basic browser/OS detection...