Browser detection with JS to set a php variable value error.
Posted: Wed Nov 19, 2008 1:59 am
This works:
But this does not:
PHP:
On any browser including Opera with this other code I get "different" on screen, "$altc" gets overwritten.
What could be the problem?
Code: Select all
<script type="text/javascript">
if (window.opera)
{
document.write('opera');
}
else
{
document.write('different browser');
}
</script>Code: Select all
<script type="text/javascript">
if (window.opera)
{
document.write('<?php $altc="yes"; ?>');
}
else
{
document.write('<?php $altc=""; ?>');
}
</script>PHP:
Code: Select all
<?php
if ($altc==yes) {
echo "opera";
}
else {
echo "different";
} ?>What could be the problem?