Jump to content

PHP 5.4.0 released! =D


Andy-H

Recommended Posts

Anyone got it up and running yet?

 

 

http://php.net/releases/5_4_0.php

 

 

Looking through the notes the features I'm happiest about are the

<?= $var; ?>

being enabled regardless of short tag open, but maybe I'm just lazy? lol

 

 

And the new short array syntax:

foreach( [ 1, 2, 3] AS $val ) {}

especially as earlier today I was working on a js-intensive application and started writing a PHP script straight afterwards and wrote

<?php
array = array('test', 'test2');
for ( var i in array ) // lol

 

 

Also the class member access on instantiation could be useful for lazy programmers like me lol

Link to comment
Share on other sites

I was messing with the beta's a bit.  I haven't tried running any of my existing stuff on it, might give it a try over the weekend on my laptop.

 

Not sure how soon it'll be before I take advantage of any of the features.  Our prod stuff probably wont update for a long time.

Link to comment
Share on other sites

I like the short tag echo as i use that in my templates, and now I won't need the str_replace then eval hack if short tags is disabled.

 

The short array syntax and array-dereferencing will both be nice (eg $first=explode('.', $var)[0]);

 

Also being able to call a member function directly will be nice, I've  had a few cases where I wanted to do that, mainly with the DateTime object, eg:

$date = (new DateTime($row['date'], $usersTimeZone))->format('m/d/Y H:i');

 

It's just a shame that I probably wont really get to use any of it for a year or more.

 

Link to comment
Share on other sites

The only one I'm remotely excited about is the shortened array syntax. Coming from a lot of JS work, this is nice.

 

Ditto.

 

Hopefully JavaScript will do the same in reverse and make a few of its language constructs more like php... Ah, one can dream.

Link to comment
Share on other sites

Iv'e been building a framework around 5.4 for the last 4 months or so (link in my signature). Besides the stuff that kicken mentioned there probably not a great deal more in it. I have used traits a few times but it was a bit forced and will likely be removed eventually. I'm yet to really find a strong use case for them.

 

The built in web server has come in handy a few times as I only built 5.4's cli to start with.

Link to comment
Share on other sites

Framework looks really good, although I don't really understand the need for events in a blocking environment? (I'm sure this is just down to a lack of experience/knowledge on my part, I just don't get it because php is parsed left-right top-bottom)

 

 

I know you said in your blog that you will be able to register an option to validate by regex, will this also be capable of implementing filter_var with various flags? (such as validate email)

 

 

 

 

Link to comment
Share on other sites

A bit OT, but what the heck...

 

Framework looks really good, although I don't really understand the need for events in a blocking environment? (I'm sure this is just down to a lack of experience/knowledge on my part, I just don't get it because php is parsed left-right top-bottom)

 

The events are just a fancy name for "hooks" really. It simply allows you to inject code into certain points in the bootstrap process. You could of course also use this same functionality within your application to make it easily extendable.

 

I know you said in your blog that you will be able to register an option to validate by regex, will this also be capable of implementing filter_var with various flags? (such as validate email)

 

A type validator (assuming your talking about the opt component) can be any function that returns a bool. To use your example:

 

$ops = $this->setOptions([
    'user_email' => (new Option())
        ->addTypeValidator('email', function($value) {
            return filter_var($value, FILTER_VALIDATE_EMAIL));
        })->type('email')
], $options);

Link to comment
Share on other sites

Yeh, our work servers probably won't either, might install it locally and have a mess around tho.

 

I doubt you will see many companies upgrading before at least 5.4.1, when they will undoubtedly fix a bunch of issues with it.

Link to comment
Share on other sites

I don't really know what bootstrap is, I mean, I'm assuming it's a design pattern, all I could figure from the documents about it is that it's a simple process which delegates tasks to run more complicated code?

 

 

I'm guessing hooks is pretty self-explanatory, you hook code into a main processing script to act upon certain variables?

 

 

From writing that I figure a hook is a kind of bootstrap?

 

 

Will you be able to create re-usable options? Such as checking if the post array has a key containing "email" and running that through filter validate email? I think that would be quite good, then maybe an opt-out? Like this post key contains "email" but I don't want to validate it as an email, kind of code automation.

Link to comment
Share on other sites

I don't really know what bootstrap is

 

Bootstrap is refers to the startup process.  It encompasses everything you need to do just to get a system up and running, before you actually start processing anything.  This is things like including any necessary classes, setting up your database connection, starting up a session, etc. 

 

 

Link to comment
Share on other sites

Will you be able to create re-usable options? Such as checking if the post array has a key containing "email" and running that through filter validate email? I think that would be quite good, then maybe an opt-out? Like this post key contains "email" but I don't want to validate it as an email, kind of code automation.

 

That sort of validation is at a much higher level to where the framework currently is. At the moment, I'm just focused on getting the very low level functionality in place.

 

The Opt component (which is what I assume your looking at) is not designed to validated user input per say. It is designed to validate function arguments where type hinting is not available.

Link to comment
Share on other sites

If you want to use xDebug with php 5.4.0 - I have compiled the windows dll myself (with only 1 issue: max_exec_time isn't modified so have to modify in php.ini - nothing major).

 

Or I can outline steps to compile xdebug yourself. (fairly lengthy, from tools download to using the dll in netbeans can take up to an hour depending on network speed.)

Link to comment
Share on other sites

If you want to use xDebug with php 5.4.0 - I have compiled the windows dll myself (with only 1 issue: max_exec_time isn't modified so have to modify in php.ini - nothing major).

 

Or I can outline steps to compile xdebug yourself. (fairly lengthy, from tools download to using the dll in netbeans can take up to an hour depending on network speed.)

 

Lucky for me I use a nice up to date Linux distro that already has php5.4 and all of it's extensions available (has done since the alpha releases).

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.