Jump to content

PHP 6, can't wait


Ninjakreborn

Recommended Posts

I wrote this whole thing, and lost it because the browser crashed, from now on, I edit it in a notepad, then put it on the site, that really pissed me off.


http://www.corephp.co.uk/archives/19-Prepare-for-PHP-6.html


[quote]Unicode

Unicode support at present can be set on a per request basis. This equates to PHP having to store both Unicode and non-Unicode variants of class, method and function names in the symbol tables. In short - it uses up more resources. Their decision is to make the Unicode setting server wide, not request wide. Turning Unicode off where not required can help performance and they quote some string functions as being up to 300% slower and whole applications 25% slower as a result. The decision to move it to the php.ini in my mind does take the control away from the user, and puts it into the hands of the Web Host.

If you compile PHP yourself or are responsible for this on your servers then you may be interested to know that PHP 6 will require the ICU libs (regardless if Unicode is turned on or off). The build system will bail out if the required ICU libs cannot be found. In a nutshell, you'll have another thing to install if you want to compile PHP.[/quote]
Not exactly sure what this means, but it sounds good.

[quote]Register Globals to go

Say goodbye folks, this one is finally going. It will no longer be an ini file setting, and if found it will raise an E_CORE_ERROR, pointing you to the documentation on why it's "bad". This means that PHP6 will finally break all PHP3 era scripts (or any script using reg globals) with no recourse at all but to re-code it. That's a bold move, but a needed one.[/quote]
Finally a step in the right direction, getting rid of something that should have never been there in the first place.

[quote]Magic Quotes to go

The magic quotes feature of PHP will be going, and as with register globals it's going to raise an E_CORE_ERROR if the setting is found anywhere. This will affect magic_quotes, magic_quotes_sybase and magic_quotes_gpc.
Safe Mode to go

This may please developers who have web hosts that insist upon safe mode! But it will now go totally, again raising an E_CORE_ERROR if found. The reason is that apparently they felt it gave the 'wrong signal', implying that it made PHP secure, when infact it didn't at all. open_basedir will (thankfully) be kept.[/quote]
Magic quotes has always annoyed me, this is going to help a lot, with a lot of things.  It's going to make programming a better place.

[quote]'var' to alias 'public'

PHP4 used 'var' within classes. PHP5 (in its OO move) caused this to raise a warning under E_STRICT. This warning will be removed in PHP6 and instead 'var' will mean the same thing as 'public'. This is a nice move but I if anyone has updated their scripts to work under E_STRICT in PHP5 it will be a redundant one for them.[/quote]
additions and changes to the var keyword

[quote]Register Long Arrays to go

Remember the HTTP_*_VARS globals from yesteryear? Well if you're not already using $_GET, $_POST, etc - start doing so now, because the option to enable long arrays is going (and will throw an E_CORE_ERROR).[/quote]
Now we can  finally move forward in the future, towards better programming styles.
No more use of as many deprecated elements

[quote]PHP Engine Additions

64 bit integers
A new 64 bit integer will be added (int64). There will be no int32 (it is assumed unless you specify int64)

Goto
No 'goto' command will be added, but the break keyword will be extended with a static label - so you could do 'break foo' and it'll jump to the label foo: in your code.

ifsetor()
It looks like we won't be seeing this one, which is a shame. But instead the ?: operator will have the 'middle parameter' requirement dropped, which means you'd be able to do something like this: "$foo = $_GET['foo'] ?: 42;" (i.e. if foo is true, $foo will equal 42). This should save some code, but I personally don't think it is as 'readable' as ifsetor would have been.

foreach multi-dim arrays
This is a nice change - you'll be able to foreach through array lists, i.e. "foreach( $a as $k => list($a, $b))".

{} vs []
You can currently use both {} and [] to access string indexes. But the {} notation will raise an E_STRICT in PHP5.1 and will be gone totally in PHP6. Also the [] version will gain substr and array_slice functionality directly - so you could do "[2,]" to access characters 2 to the end, etc. Very handy.[/quote]
Bad use for barand, is that they are not using go-to yet either.  Sounds like they are moving in the right direction. 

[quote]Additions to PHP

APC to be in the core distribution
The opcode cache APC will be included in the core distribution of PHP as standard, it will not however be turned on by default (but having it there saves the compilation of yet another thing on your server, and web hosts are more likely to allow it to be enabled)

Hardened PHP patch
This patch implements a bunch of extra security checks in PHP. They went over it and the following changes will now take place within PHP: Protection against HTTP Response Splitting will be included. allow_url_fopen will be split into two: allow_url_fopen and allow_url_include. allow_url_fopen will be enabled by default. allow_url_include will be disabled by default.

E_STRICT merges into E_ALL
Wow, this is quite a serious one! E_STRICT level messages will be added to E_ALL by default. This shows a marked move by the PHP team to educate developers on 'best practises' and displaying language-level warnings in a "Hey, you're doing it the wrong way".

Farewell <%
They will remove support for the ASP style tags, but the PHP short-code tag will remain (<?) - so to those on php general who reckon the short-tag is 'depreceated' - hah! ;-)[/quote]
Finally some needed improvements to error handling, as well as removing those ugly tags.

http://www.dotvoid.com/view.php?id=57

Another link to reinforce a lot of the things mentioned above.

This goes over a lot of the same stuff, and reinforces the stuff on the first link

http://en.wikipedia.org/wiki/PHP

Another re-inforcement (trusted one), of the things mentioned above.

[quote]Future development

PHP 6, in development as of October 2006, aims to address some of PHP 5's shortcomings.[12]

    * Native Unicode support will be added;
    * The magic_quotes option will be removed;
    * The register_globals option will be removed;
    * The safe_mode option will be removed.

In addition, there has been discussion of adding namespace support.[/quote]
With  magic quotes, register globals, and safe mode being taken out it will make a better, more secure work enviroment in my opinions.

http://news.php.net/php.internals/17883
This is from the creator himself it reinforces my key points

[quote]1. Remove register_globals completely

2. Remove magic_quotes_*

3. Add input filter extension which will include a mechanism for
  application developers to very easily turn it off which would swap
  the raw GPC arrays back in case the site had it turned on by default.

4. Include an opcode cache by default.  A lot of work has gone into
  pecl/apc recently, but I am not hung up on which one goes in.

5. Remove safe_mode and focus on open_basedir

6. Remove some stuff that has been marked deprecated since PHP 3/4

A couple of others that we could consider, but I don't actually think
wins us much apart from academic purity (which I have never been all
that keen on) are:

7. Make identifiers case-sensitive

8. Remove various function aliases[/quote]
That coming out of the owners mouth reinforces thoughts for me a lot

http://news.php.net/php.internals/17668

Another piece of information about it.

http://www.php.net/~derick/meeting-notes.html

Now for my favorite link, the direct link to there meeting information related to EVERYTHING they are talking about for php 6.  The perfect place to be kept up to date.

[quote]# 1. Unicode

    * 1.1 Unicode on/off modes
    * 1.2 Different String Types
    * 1.3 Extension upgrading
    * 1.4 Bundling ICU
    * 1.5 Filename Encoding
    * 1.6 Collator Caching
    * 1.7 Optimising []
    * 1.8 Locale Sensitivity
    * 1.10 Conversion Errors
[/quote]
Not sure what unicode is exactly, have to check up on that.

[quote]# 2. Cleanup of Functionality

    * 2.1 register_globals
    * 2.2 magic_quotes
    * 2.3 safe_mode
    * 2.4 Deprecated Behaviour
    * 2.5 zend.ze1_compatibility mode
    * 2.6 Support for Freetype 1 and GD 1
    * 2.7 open_basedir
    * 2.8 dl()
    * 2.9 CGI/FastCGI mode
    * 2.10 Dynamic class inheritance
    * 2.11 register_long_arrays, HTTP_*_VARS
    * 2.12 old type constructors
    * 2.13 Case sensitivity of identifiers
    * 2.14 break $var

[/quote]
To me this "cleanup" is going to greatly improve the speed at which php run's, and greatly increase it's security, and overall functionality.  These are some much needed improvements, and forced behaviours.

[quote]# 4 Engine Additions

    * 4.1 Add a 64bit integer
    * 4.2 Adding "goto"
    * 4.3 ifsetor() as "replacement" for $foo = isset($foo) ? $foo : "something else"
    * 4.4 Allow foreach syntax for multi-dimensional arrays
    * 4.5 Cleanup for {} vs. []
    * 4.6 Changes to the shut-up (@) operator that disallow (@ini_set(...))
    * 4.7 Allow foreach() without "as" part (I guess for iterators)
    * 4.8 Named Parameters
    * 4.9 Make parameter order consistent over all functions
    * 4.10 Minor function changes: microtime()[/quote]

[quote]4.2 Adding "goto"

Issue: Goto is currently missing in PHP, and although there is a limited use for this construct in some cases it can reduce the amount of code a lot.

Discussion: There are some inherent problems with implementing goto, as jumping into a foreach() loop will almost be impossible as at the start of the loop something is initialised. The same is most likely true for other loop constructs.

As goto will most often be used to jump out of nested if statements, we think that restricting the construct so that you can only jump out of a construct is possible. Similarly restricting the construct so that you can only jump down should satisfy people who do not want the ability to jump all over the place.

The name "goto" is misleading, and often associated with BAD THINGS(tm). Because our proposed solution is not a real GOTO construct, we will instead reuse the "break" keyword, and extend it with a static label.

An example of using a labeled break:

<?php
for ($i = 0; $i < 9; $i++)
{
        if (true) {
                break blah;
        }
        echo "not shown";
blah:
        echo "iteration $i\n";
}
?>

Conclusions:

  1. We extend "break" by allowing breaking to a label.
  2. We ask Sara to make a patch for this, and we see how it is going to look like. We decide on that.[/quote]

They finally seem to start addressing the issue to some extent that barand brought up awhile back, about them not having GoTo

[quote]# 5. Changes to OO functionality

    * 5.1 "function require __construct(" to force calling the parent's constructor
    * 5.2 Allow interfaces to specify the __construct() signature
    * 5.3 Implement inheritance rules for type hints
    * 5.4 Late static binding using "this" without "$" (or perhaps with a different name)
    * 5.5 Object casting to primitive types
    * 5.6 name spaces
    * 5.7 Using an undefined property in a class with defined properties should throw a warning
    * 5.8 Type-hinted properties and return values
    * 5.10 Method calls
    * 5.11 ReflectionClass cache in zend_class_entry* and support "$this::class"
    * 5.12 Delegates[/quote]
Since I am just getting into OOP, I am hoping these changes and additions make OOP functionality even better, and more well rounded in PHP as a whole.

[quote]# 6 Additions

    * 6.1 Add an opcode cache to the distribution (APC)
    * 6.2 Merge Hardened PHP patch into PHP
    * 6.3 Sand boxing or taint mode
    * 6.4 All non-fatal errors should be marked in extensions as E_RECOVERABLE_ERROR
    * 6.5 All non-fatal errors should become exceptions
    * 6.6 E_STRICT on by default
    * 6.7 Remove support for <?, <% and <script language="PHP"> and add "<?php =$var?>"
    * 6.8 Rewrite build system
    * 6.9 Added persistent flag to zval struct
    * 6.10 Read-only properties[/quote]

A lot of additions, and changes to the actual error handling, remove shitloads of deprecated and outdated tags, and everything else.  I can't wait until this new version of PHP come's out and take's off.

Still waiting for more servers tot ake to PHP 5.  Hopefully both of these things will come to pass soon.






Link to comment
Share on other sites

I like the idea about magic quotes, register globals, safe mode and register long arrays to be removed, but I unfortunately think that this will make many hosts not upgrade or wait long time. At least we will get people code their scripts better. I also like that ASP style tags are removed, there isn't really any good use for them. I like that you are able to do e.g. [tt]$var[2,5][/tt] like in Python.
Link to comment
Share on other sites

[quote author=SemiApocalyptic link=topic=122655.msg506151#msg506151 date=1168966258]
Wouldn't get too excited, the majority of hosts are still running version 4, even though 5 has been out for ages... I bet that v4 is still common-place when 6 is released.
[/quote]
Yeah, it's so annoying when servers are running stuff like Apache 1.3, PHP 4 and MySQL 4. Why don't those #¤%"! upgrade their software?!?!?!
Link to comment
Share on other sites

Because, like most businesses, they adhere to the philosophy of "if it ain't broke, don't fix it." And unfortunately, their idea of it being "fixed" is that their site runs perfectly fine with the current version, so therefore it's not broken.  Unfortunately, the only way to get past that mentality is for their stuff to break.

@businessman: I have a hard time believing that Barand is a supporter of "goto" style programming...
Link to comment
Share on other sites

[quote]@businessman: I have a hard time believing that Barand is a supporter of "goto" style programming...[/quote]

http://www.phpfreaks.com/forums/index.php/topic,122040.0.html
[quote]
In response to question 9 I have to say that I prefer "spaghetti code". The best instruction ever is the GOTO statement. From within a for-loop or a while-loop, or, for that matter within a function, you can (in Basic anyway) jump to any part of your program. This gives great flexibility and freedom of movement to the programmer and the lack of GOTO in PHP is, for me, a grave oversight and I am really tempted to go back to VB.[/quote]
Link to comment
Share on other sites

[quote author=Crayon Violent link=topic=122655.msg506206#msg506206 date=1168969006]
uh...the word 'sarcasm' comes to mind...
[/quote]

Yeah, I was just about to post the same thing, in addition that, in my experience, most programmers treat GOTO as a (bad) four-letter word.  Hell, in my university, any student caught using GOTO would automatically fail that assignment.
Link to comment
Share on other sites

Like the above comments, I'm not a fan of the GOTO style, either; however, I must say, from an error handling perspective, I am rather excited about being able to [i]break foo[/i] depending on different actions or errors that the code is presented with.
Link to comment
Share on other sites

[quote]Like the above comments, I'm not a fan of the GOTO style, either; however, I must say, from an error handling perspective, I am rather excited about being able to break foo depending on different actions or errors that the code is presented with.[/quote]
Yes that is going to be good.
You can have a loop at the top, and have it cycle through some actions, then break it to the part of code, that it relates to.  Then cycle it again, and have it break back up to the otp, I can already come up with some good uses for that.
Link to comment
Share on other sites

[quote author=businessman332211 link=topic=122655.msg506229#msg506229 date=1168970552]
;D

I never had experience specifically with GOTO, I know it's a way a lot of the older programmers use to have to program in other languages.  I have heard that it is used heavily in other languages too

Does it have anything to do with OOP?
[/quote]

This was my professors' stance on GOTO: GOTO is used primarily by those 'programmers' who are too lazy/ignorant to write correctly formed, logical code.  Since they all had their Ph. d's in computer science, and had 20+ years of experience with C, C++, assembly, and other things, I'll trust their judgement on this.

GOTO has nothing to do with OOP.  It basically just says "Go to this specified chunk (line) of code when a certain condition is met."  It's power comes from it not being limited in scope.  It's a very powerful feature, and as such, a lot of newbie coders rely on it because it's so easy to use. The problem is that this leads to spaghetti code, which is both hard to read and hard to extend/fix because of the tight coupling it produces.  A change in one part of code will create problems that cascade throughout the rest of the code.  This is the antithesis of OOP, whose design philosophy is to [i]reduce or negate[/i] coupling.  The pinnacle of OOP code should be seen as modularity -- something beneficial that can be plugged into code without screwing things up and without needing much (if any) modification of the original code in order to work.
Link to comment
Share on other sites

The things I'm interested in reading about re: PHP6 is namespaces and the new OOP goodies they're including.  I never got into namespaces in college...dropped out of the cs department before I got to that point.  Is it basically just a way for a coder to create their own named local scope?  Or is it something else?  Also, any word on if PHP6 will allow for multiple inheritance or true polymorphism?
Link to comment
Share on other sites

Bussinessman, a link to the site could have down with you pointing out the finer points of what you liked.  It would have saved you much work, and then you could only comment on the additions/subtractions of stuff in php 6 that you think were a good move on the developers part.  That's what I personally would have done, but I'm a time manager and copy and pasting the whole thing, then commenting on all of it, when some of the stuff i could care less about, is just a waste of my time.  :)  Just thought I would help out for the next big article you find interesting.  BTW, I got you a few OOP and MVC links that I am going to PM to you to help in your Framework. It should answer all your present questions you have posted on the forums, and hopefully address any future questions that might arise.
Link to comment
Share on other sites

If anyone here has been playing with the snaps I have a few questions.

1. is there any documentation about has been and what has not been added to the snaps
2. are name spaces already implemented in the snaps?

if name spaces are already implemented I'm tempted to download and compile a copy.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.