Hi there, I'm now to this forum. I cannot get this piece of PHP code to work. Basically, the PHP code detects which browser the user is using, and then display the XML file and an XSL stylesheet depending on the browser they are using - but it doesn't work! Although echo ("<h3>IE</h3>"); and the other 2 work does work, nothing else does. Hope you can help. Thanks, Julie.
<html>
<head><title>Determining Browser Type</title></head>
<body>
<h1>Determining Browser Type</h1>
<br />
<?php
if(substr_count($_SERVER["HTTP_USER_AGENT"], "MSIE") > 0){
echo ("<h3>IE</h3>");
$xsltproc=xslt_create();
$xslt_result = xslt_process($xsltproc,'uk.xml','IE.xsl');
echo $xslt_result;
xslt_free($xsltproc);
}
else if(substr_count($_SERVER["HTTP_USER_AGENT"], "Opera") > 0){
echo ("<h3>Opera</h3>");
$xsltproc=xslt_create();
$xslt_result = xslt_process($xsltproc,'uk.xml','Opera.xsl');
echo $xslt_result;
xslt_free($xsltproc);
}
else if(substr_count($_SERVER["HTTP_USER_AGENT"], "Firefox") > 0){
echo ("<h3>firefox</h3>");
$xsltproc=xslt_create();
$xslt_result = xslt_process($xsltproc,'uk.xml','Firefox.xsl');
echo $xslt_result;
xslt_free($xsltproc);
}
?>
</body>
</html>
$xsltproc=xslt_create() - help please!
Moderator: General Moderators
Re: $xsltproc=xslt_create() - help please!
Do you have error handling enabled?hippyju wrote:Hi there, I'm now to this forum. I cannot get this piece of PHP code to work. Basically, the PHP code detects which browser the user is using, and then display the XML file and an XSL stylesheet depending on the browser they are using - but it doesn't work! Although echo ("<h3>IE</h3>"); and the other 2 work does work, nothing else does. Hope you can help. Thanks, Julie.
<html>
<head><title>Determining Browser Type</title></head>
<body>
<h1>Determining Browser Type</h1>
<br />
<?php
if(substr_count($_SERVER["HTTP_USER_AGENT"], "MSIE") > 0){
echo ("<h3>IE</h3>");
$xsltproc=xslt_create();
$xslt_result = xslt_process($xsltproc,'uk.xml','IE.xsl');
echo $xslt_result;
xslt_free($xsltproc);
}
else if(substr_count($_SERVER["HTTP_USER_AGENT"], "Opera") > 0){
echo ("<h3>Opera</h3>");
$xsltproc=xslt_create();
$xslt_result = xslt_process($xsltproc,'uk.xml','Opera.xsl');
echo $xslt_result;
xslt_free($xsltproc);
}
else if(substr_count($_SERVER["HTTP_USER_AGENT"], "Firefox") > 0){
echo ("<h3>firefox</h3>");
$xsltproc=xslt_create();
$xslt_result = xslt_process($xsltproc,'uk.xml','Firefox.xsl');
echo $xslt_result;
xslt_free($xsltproc);
}
?>
</body>
</html>
I tried running your code, and I received this
Code: Select all
Determining Browser Type
firefox
Fatal error: Call to undefined function xslt_create() in /home/www/public_html/quote/test/index.php on line 24