[kdewebdev-webdeveloper] php SuperGlobals question

obennett obennett at hartford.edu
Fri Aug 6 03:30:17 EDT 2004


On Thursday 05 August 2004 21:51, Eric Laffoon wrote:
> 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?
>
Thanks a lot. That's exactly what I needed. Once I did  
$_SERVER[''HTTP_USER_AGENT''] problem solved :)
> Otherwise maybe try
> global $HTTP_USER_AGENT;
> and see if that works?


More information about the kdewebdev-webdeveloper mailing list