RE: [PHP] question on <?php and $HTTP_POST_VARS (possibly unrelat ed)
| From: | Ford, Mike [LSS] | Date: | Thu, 22 May 2003 16:38:00 +0000 |
| Subject: | RE: [PHP] question on <?php and $HTTP_POST_VARS (possibly unrelat ed) | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-148577@lists.php.net to get a copy of this message | ||
> -----Original Message-----
> From: Jason Jacobs [mailto:jason@factory7.com]
> Sent: 22 May 2003 17:12
>
> We are setting up a new server with the Apache config
> described at the end of the email and PHP 4.2.2, and I came
> across some issues.
I hope this is not a production server -- the combination of Apache 2.0.40
and PHP 4.2.2 is at best beta-quality, and gives rise to a number of known
issues. The latest Apache 1.3.x (.27 last time I looked) is warmly
recommended for use with PHP -- if you absolutely must have Apache 2, go for
Apache 2.0.45 with PHP 4.3.2 (due out in the next week or so).
>
> I took a site I built on another server and only ever used <?
> to designate my php and never ever used $HTTP_POST_VARS (or
> GET), nor did I refer to session variables as anything but
> $sessionvar. In fact, a package I downloaded had all passed
> variables referred to with $HTTP_GET_VARS['foo'] and it
> didn't work. I had to take that out and refer to it only as $foo.
Well, that I don't understand -- if anything, it should have been the other
way around.
>
> On this new server, my code broke. The guy who set up the
> server said the <? needed to be changed to <?php, so he
> grep-ed it and changed those. Then I found that variables
> weren't being passed to other pages, but they did once I
> added $HTTP_GET_VARS.
As it's PHP 4.2.2, use $_GET, $_POST, etc.
> I thought this was a configuration thing in Apache, or PHP at
> least. I also thought <?php was the "old" way and you didn't
> need that anymore. Am I wrong?
Yes. <?php is the new and XML-compliant way, and is also the most portable.
If you're aiming to write code that will run on any site, use <?php -- that
will work regardless of PHP configuration.
> Is it possible to easily
> allow this server to accept "naked" variables and <? only?
> Thanks for your help.
It's possible, but not generally recommended. The configuration option you
are looking for for "naked" variables is register_globals, but you should
read up about why turning this on is discouraged before you do so. For <?
you want short_open_tags, but you can't have "only" <? -- <?php always
works, and short_open_tags just gives you <? in addition.
Cheers!
Mike
---------------------------------------------------------------------
Mike Ford, Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS, LS6 3QS, United Kingdom
Email: m.ford@lmu.ac.uk
Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211