KevinM1 Posted October 12, 2006 Share Posted October 12, 2006 I asked this in the miscellaneous category a while back and never got a response, so I figured I'd ask here as it seems like a better section in which to post this.I have the Larry Ullman/Peachpit book (the one up to PHP4 and MySQL4). I saw someone make a comment that the book uses the 'old' PHP syntax. What is an example of the 'old' synatx, and what is an example of the 'new' syntax?Thanks :) Quote Link to comment https://forums.phpfreaks.com/topic/23805-general-syntax-question/ Share on other sites More sharing options...
wildteen88 Posted October 13, 2006 Share Posted October 13, 2006 I guess what they mean by "old syntax" is the use of register_globals.For example if your PHP setup has register_globals enabled, instead of using $_GET['url_var_here'] you used $url_var_hereThe "new syntax" is to disable register_gloabls (which is off by default as of PHP4.2.x) and use the new superglobals which are $_GET, $_POST, $_SESSION, $_COOKIE etcAnother new sytax change is the old superglobals which are the $HTTP_*_VARS. For example instead of using $HTTP_GET_VARS you use $_GET instead for accessing vars in the URL. Or instead of $HTTP_POST_VARS your use $_POST etc. Quote Link to comment https://forums.phpfreaks.com/topic/23805-general-syntax-question/#findComment-108241 Share on other sites More sharing options...
KevinM1 Posted October 13, 2006 Author Share Posted October 13, 2006 [quote author=wildteen88 link=topic=111347.msg451290#msg451290 date=1160733889]I guess what they mean by "old syntax" is the use of register_globals.For example if your PHP setup has register_globals enabled, instead of using $_GET['url_var_here'] you used $url_var_hereThe "new syntax" is to disable register_gloabls (which is off by default as of PHP4.2.x) and use the new superglobals which are $_GET, $_POST, $_SESSION, $_COOKIE etcAnother new sytax change is the old superglobals which are the $HTTP_*_VARS. For example instead of using $HTTP_GET_VARS you use $_GET instead for accessing vars in the URL. Or instead of $HTTP_POST_VARS your use $_POST etc.[/quote]I dunno if that's what the other person was talking about as my version of the book only uses the current superglobals. I think it may have something to do with 'arrow' syntax ($something -> something) that I see in some people's code. How does that kind of thing work? Quote Link to comment https://forums.phpfreaks.com/topic/23805-general-syntax-question/#findComment-108265 Share on other sites More sharing options...
Jenk Posted October 13, 2006 Share Posted October 13, 2006 they may have been referring to short tag '<?'Wihtout an example it's difficult to say :p Quote Link to comment https://forums.phpfreaks.com/topic/23805-general-syntax-question/#findComment-108279 Share on other sites More sharing options...
KevinM1 Posted October 13, 2006 Author Share Posted October 13, 2006 [quote author=Jenk link=topic=111347.msg451328#msg451328 date=1160741510]they may have been referring to short tag '<?'Wihtout an example it's difficult to say :p[/quote]Yeah, and of course the post I originally referred to didn't have any examples, only a passing mention of old vs. new syntax.Oh well, so long as I can get my scripts to work, it doesn't really matter. :) Quote Link to comment https://forums.phpfreaks.com/topic/23805-general-syntax-question/#findComment-108347 Share on other sites More sharing options...
akitchin Posted October 13, 2006 Share Posted October 13, 2006 the arrow syntax isn't technically old, that's just object-oriented syntax. you refer to methods and variables that belong to objects using $object_name->method().as for "old" syntax, there have been small changes between PHP versions (obviously). the biggest is the superglobals by far, and if those are fine in your book, i can't see any reason to be concerned. i myself haven't progressed to using PHP 5 yet, so i can't comment there, but apart from that it's probably just function parameter orders, etc. Quote Link to comment https://forums.phpfreaks.com/topic/23805-general-syntax-question/#findComment-108350 Share on other sites More sharing options...
Jenk Posted October 13, 2006 Share Posted October 13, 2006 Perhaps they refer to use of classes with the following:[code]<?phpclass Foo var $bar; // constructor function Foo() { $this->bar = 'foobar'; }}?>[/code]as opposed to php5 syntax:[code]<?phpclass Foo{ private $bar; public function __construct() { $this->bar = 'foobar'; }}?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/23805-general-syntax-question/#findComment-108384 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.