[kdewebdev-webdeveloper] php SuperGlobals question

Eric Laffoon eric at kdewebdev.org
Thu Aug 5 19:51:32 EDT 2004


On Thursday 05 August 2004 5:44 pm, obennett wrote:
> Hey all. I have a prob with php and the register_globals directive being
> off. I have the following code which I thought would work with
> register_globals off seeing that they are superglobals, however if I do set
>  register_globals to be off it doesn't work:
>
> <?php
> if(stristr($_SERVER["HTTP_ACCEPT"],"application/xhtml+xml")){
>   header("Content-Type: application/xhtml+xml");
>   echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
>   echo ('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
> "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">');
> }
> elseif(stristr($HTTP_USER_AGENT,"Opera 7")||
> stristr($HTTP_USER_AGENT,"Opera/7")
>
> ||stristr($HTTP_USER_AGENT,"Safari")||
>
> stristr($HTTP_USER_AGENT,"W3C_Validator")
>
> ||stristr($HTTP_USER_AGENT,"Konqueror/3.3")){
>
>   header("Content-Type: application/xhtml+xml");
>   echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
>   echo ('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
> "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">');
> } else {
>   header("Content-Type: text/html");
>   echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
>   echo ('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">');
> }
> ?>
>
> any idea why it might not be working?
Here's my idea... $HTTP_USER_AGENT isn't a superglobal. Is there a $_SERVER or 
other superglobal array variable for it?

Otherwise maybe try
global $HTTP_USER_AGENT;
and see if that works?
-- 
Eric Laffoon - Quanta+ Team Leader 
http://kdewebdev.org  eric at kdewebdev.org
Mailing list - http://mail.kde.org/mailman/listinfo/quanta
GPG Fingerprint: 48FB 218D 747F A54A 319D EE98 4A25 794E A453 004B
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://momo.creolmail.org/pipermail/kdewebdev-webdeveloper/attachments/20040805/a9120b74/attachment.pgp


More information about the kdewebdev-webdeveloper mailing list