$xsltproc=xslt_create() - help please!

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!

Moderator: General Moderators

Post Reply
hippyju
Forum Newbie
Posts: 1
Joined: Thu Dec 18, 2008 10:51 am

$xsltproc=xslt_create() - help please!

Post by hippyju »

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>
syth04
Forum Newbie
Posts: 14
Joined: Thu Dec 18, 2008 12:12 am

Re: $xsltproc=xslt_create() - help please!

Post by syth04 »

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>
Do you have error handling enabled?

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
 
Which means I do not have the function installed in my php server
Post Reply