Jump to content



Photo
- - - - -

PHP 7


  • Please log in to reply
63 replies to this topic

#1   cornishpirate

cornishpirate
  • Members
  • 136 posts
  • Real Name:Alan
  • Location:Cornwall, England

Posted 22 August 2015 - 10:51

Have just been playing with PHP 7 RC1 using these instructions as a guide:

 

https://phpdave.word...ows-in-3-steps/

 

Could only use the built-in webserver and php.ini needed tweeking for mysqli but, all in all, a very simple process.

 

Using my heavily modified RC2a system, I managed to load all pages very easily and VERY FAST!

 

Encouraging.

 

 



#2   bruyndoncx

bruyndoncx

    osCommerce Teenager

  • Members
  • 3,786 posts
  • Real Name:Carine Bruyndoncx
  • Gender:Female
  • Location:Belgium/ Antwerp/ Turnhout/ Arendonk

Posted 22 August 2015 - 12:15

Lucky you :D - I've been cleaning up my custom code while trying to get 5.4/5.5 working.

KEEP CALM AND CARRY ON
FYI Upgrade to the highest PHP version you can( PHP 5.5/5.6 or 7.1  and get big performance improvements for free)

But be aware php 5.5 is more strict about things.
UTF8-without BOM, no extra spaces allowed at the beginning or end of your php file, or your redirects wont work.
No double declarations of functions allowed - used to slip through the cracks ...

 

Find the most frequent unique errors to fix:

grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt


#3   MrPhil

MrPhil
  • Members
  • 7,014 posts
  • Real Name:Phil
  • Gender:Male

Posted 22 August 2015 - 14:55

PHP 7? Was PHP 6 ever released? Are you sure that isn't PHP 5.7?



#4   ArtcoInc

ArtcoInc
  • Members
  • 700 posts
  • Real Name:Malcolm

Posted 22 August 2015 - 14:58

@MrPhil

 

https://secure.php.n...#id2015-08-21-1

 

Malcolm



#5   MrPhil

MrPhil
  • Members
  • 7,014 posts
  • Real Name:Phil
  • Gender:Male

Posted 22 August 2015 - 16:02

Um, OK. If PHP 6 is still bleeding edge and apparently not in production use anywhere, I wonder why anyone would even bother playing with PHP 7 at this time. Whatever.



#6   cornishpirate

cornishpirate
  • Members
  • 136 posts
  • Real Name:Alan
  • Location:Cornwall, England

Posted 22 August 2015 - 16:57

Because it will be released this year and the performance improvement is amazing.

Check out the benchmarks.

#7   John W

John W

    Woof Woof!

  • Members
  • 627 posts
  • Real Name:John W.
  • Gender:Male
  • Location:Orlando, Fl

Posted 22 August 2015 - 17:14

PHP 6 is not going to be released.


I'm not really a dog.


#8   cornishpirate

cornishpirate
  • Members
  • 136 posts
  • Real Name:Alan
  • Location:Cornwall, England

Posted 22 August 2015 - 21:07

 

Are you sure that isn't PHP 5.7?

 

There isn't a PHP 5.7.

 

Details about PHP 7.0 RC1 are at http://www.php.net

 

Extract:

 

 

PHP 7.0.0 comes with new version of the Zend Engine with features such as (incomplete list):

  • Improved performance: PHP 7 is up to twice as fast as PHP 5.6
  • Consistent 64-bit support
  • Many fatal errors are now Exceptions
  • Removal of old and unsupported SAPIs and extensions
  • The null coalescing operator (??)
  • Combined comparison Operator (<=>)
  • Return Type Declarations
  • Scalar Type Declarations
  • Anonymous Classes

 



#9   MrPhil

MrPhil
  • Members
  • 7,014 posts
  • Real Name:Phil
  • Gender:Male

Posted 23 August 2015 - 13:05

PHP 6 is not going to be released.

 

Hmm. So PHP is taking a page from Microsoft and skipping version numbers? Lovely. Just lovely.



#10   NimaP

NimaP
  • Members
  • 164 posts
  • Real Name:wdwad
  • Gender:Male

Posted 02 November 2015 - 18:39

So i've updated my site to PHP5.6 and it works fine. Will I need to do anything else when PHP7 comes out?



#11   ArtcoInc

ArtcoInc
  • Members
  • 700 posts
  • Real Name:Malcolm

Posted 02 November 2015 - 20:55

Hmm. So PHP is taking a page from Microsoft and skipping version numbers? Lovely. Just lovely.

 

@MrPhil

 

From what I've heard, Microsoft went from Windows 8.1 to Windows 10 (skipping Windows 9) because ...

 

Way back when, when Microsoft moved from the Windows 95/98 platform to the Windows NT/2000/XP/etc platform, software developers had to put checks in their installation code to determine if they would/could install on a Win95/98 -vs- Win NT/2K/XP OS. So, there were checks for "Windows 9xxx".

 

While current applications may not make these checks, in order to avid problems with legacy code, Microsoft just skipped the Windows 9 version number.

 

Whether this is true or not, I can not say :-

 

Malcolm


Edited by ArtcoInc, 02 November 2015 - 20:55.


#12   MrPhil

MrPhil
  • Members
  • 7,014 posts
  • Real Name:Phil
  • Gender:Male

Posted 03 November 2015 - 14:09


Whether this is true or not, I can not say :-

 

Yeah, I've heard that account too. Even if it is true (and it could be), it indicates some pretty sloppy coding practices by developers (including Microsoft) in the past. Hard to believe but entirely possible.



#13   cornishpirate

cornishpirate
  • Members
  • 136 posts
  • Real Name:Alan
  • Location:Cornwall, England

Posted 06 November 2015 - 09:43

 

So i've updated my site to PHP5.6 and it works fine. Will I need to do anything else when PHP7 comes out?

 

Should be OK as long as you've moved to MySQli. From memory, I just changed the code to avoid Deprecated warnings on PHP 4 style constructors (methods that have the same name as the class they are defined in). Working well on my test site with PHP7 RC6, but will be giving it a comprehensive test as soon as 7.0 is released, likely to be next week.



#14   cornishpirate

cornishpirate
  • Members
  • 136 posts
  • Real Name:Alan
  • Location:Cornwall, England

Posted 14 November 2015 - 09:43

Nice free guide 'Upgrading to PHP 7"

 

http://www.oreilly.c...o-php-seven.pdf



#15   John W

John W

    Woof Woof!

  • Members
  • 627 posts
  • Real Name:John W.
  • Gender:Male
  • Location:Orlando, Fl

Posted 14 November 2015 - 16:59

Thanks for the link to the guide.  I'm only a couple chapters in reading but I like it.


I'm not really a dog.


#16   cornishpirate

cornishpirate
  • Members
  • 136 posts
  • Real Name:Alan
  • Location:Cornwall, England

Posted 10 December 2015 - 11:18

PHP7.0 now released and performing extremely well under Plesk 12.5 and nginx.

 

No new problems found yet - will continue testing for at least another month.

 

Very encouraging for the world of PHP.



#17   TaylorR

TaylorR
  • Members
  • 5 posts
  • Real Name:Rebecca Taylor
  • Gender:Female
  • Location:Toronto, Ontario

Posted 21 January 2016 - 12:55

I have also started working on PHP 7 for past 15 days and the most significant advancement which I found out in my application is that it has become quite faster. It takes very less time in loading any page.

It is really great working on PHP 7.



#18   dr_lucas

dr_lucas
  • Members
  • 331 posts
  • Real Name:Michaela
  • Gender:Female

Posted 31 January 2016 - 21:05

So i've updated my site to PHP5.6 and it works fine. Will I need to do anything else when PHP7 comes out?

 

Yes, you will need to modify classes to use __construct classes to prevent DEPRECATED errros, but other than that - it should work just fine when switching from code already compatible with 5.5 (ie. working stable without any deprecated errors on php 5.5, supports UTF-8 and mysqli) to php 7.

 

So, for example, code like this:

  class infoBoxHeading extends tableBox {    
    function infoBoxHeading($contents, $left_corner = true, $right_corner = true, $right_arrow = false) {
global $infobox_header_text, $infobox_header_link;
if (SKIN_INFOBOX_ACTIVE == 'true'){
$infobox_header_text = $contents[0]['text'];
$infobox_header_link = $right_arrow;
}
else {


      $this->table_cellpadding = '0';


      if ($left_corner == true) {
        $left_corner = tep_image(DIR_WS_IMAGES . 'infobox/corner_left.gif');
      } else {
        $left_corner = tep_image(DIR_WS_IMAGES . 'infobox/corner_right_left.gif');
      }
      if ($right_arrow == true) {
        $right_arrow = '<a href="' . $right_arrow . '">' . tep_image(DIR_WS_IMAGES . 'infobox/arrow_right.gif', ICON_ARROW_RIGHT) . '</a>';
      } else {
        $right_arrow = '';
      }
      if ($right_corner == true) {
        $right_corner = $right_arrow . tep_image(DIR_WS_IMAGES . 'infobox/corner_right.gif');
      } else {
        $right_corner = $right_arrow . tep_draw_separator('pixel_trans.gif', '11', '14');
      }


      $info_box_contents = array();
      $info_box_contents[] = array(array('params' => 'height="20" class="infoBoxHeading"',
                                         'text' => $left_corner),
                                   array('params' => 'width="100%" height="20" class="infoBoxHeading"',
                                         'text' => $contents[0]['text']),
                                   array('params' => 'height="14" class="infoBoxHeading" nowrap',
                                         'text' => $right_corner));


      $this->tableBox($info_box_contents, true);
    }
}
  }
 
Must be changed to this:
 
  class infoBoxHeading extends tableBox {
    function __construct($contents, $left_corner = true, $right_corner = true, $right_arrow = false) {
global $infobox_header_text, $infobox_header_link;
if (SKIN_INFOBOX_ACTIVE == 'true'){
$infobox_header_text = $contents[0]['text'];
$infobox_header_link = $right_arrow;
}
else {


      $this->table_cellpadding = '0';


      if ($left_corner == true) {
        $left_corner = tep_image(DIR_WS_IMAGES . 'infobox/corner_left.gif');
      } else {
        $left_corner = tep_image(DIR_WS_IMAGES . 'infobox/corner_right_left.gif');
      }
      if ($right_arrow == true) {
        $right_arrow = '<a href="' . $right_arrow . '">' . tep_image(DIR_WS_IMAGES . 'infobox/arrow_right.gif', ICON_ARROW_RIGHT) . '</a>';
      } else {
        $right_arrow = '';
      }
      if ($right_corner == true) {
        $right_corner = $right_arrow . tep_image(DIR_WS_IMAGES . 'infobox/corner_right.gif');
      } else {
        $right_corner = $right_arrow . tep_draw_separator('pixel_trans.gif', '11', '14');
      }


      $info_box_contents = array();
      $info_box_contents[] = array(array('params' => 'height="20" class="infoBoxHeading"',
                                         'text' => $left_corner),
                                   array('params' => 'width="100%" height="20" class="infoBoxHeading"',
                                         'text' => $contents[0]['text']),
                                   array('params' => 'height="14" class="infoBoxHeading" nowrap',
                                         'text' => $right_corner));


      $this->tableBox($info_box_contents, true);
    }
}
  }

As you can see, the only modification was: function infoBoxHeading changed to function __construct

I highly recommend switching to php 7, if you can.


Edited by dr_lucas, 31 January 2016 - 21:13.


#19   dr_lucas

dr_lucas
  • Members
  • 331 posts
  • Real Name:Michaela
  • Gender:Female

Posted 05 February 2016 - 10:13

Actually the specific modification example I gave is not so good, because this infoBoxHeading class extends tableBox class and in this case it would be correct to modify tableBox class first from:

class tableBox{
    function tableBox{
        // some code
    }
// more code
}

TO:

class tableBox{
   function __construct(){
    //leave it empty
   }
    function tableBox{
        // some code
    }
// more code
}

 and then on the extended class, do this:

class infoBoxHeading extends tableBox {
    function __construct($contents, $left_corner = true, $right_corner = true, $right_arrow = false) {
global $infobox_header_text, $infobox_header_link;

parent::__construct(); //calling the parent constructor, as tableBox method is being used here in this class

if (SKIN_INFOBOX_ACTIVE == 'true'){
$infobox_header_text = $contents[0]['text'];
$infobox_header_link = $right_arrow;
}
else {


      $this->table_cellpadding = '0';


      if ($left_corner == true) {
        $left_corner = tep_image(DIR_WS_IMAGES . 'infobox/corner_left.gif');
      } else {
        $left_corner = tep_image(DIR_WS_IMAGES . 'infobox/corner_right_left.gif');
      }
      if ($right_arrow == true) {
        $right_arrow = '<a href="' . $right_arrow . '">' . tep_image(DIR_WS_IMAGES . 'infobox/arrow_right.gif', ICON_ARROW_RIGHT) . '</a>';
      } else {
        $right_arrow = '';
      }
      if ($right_corner == true) {
        $right_corner = $right_arrow . tep_image(DIR_WS_IMAGES . 'infobox/corner_right.gif');
      } else {
        $right_corner = $right_arrow . tep_draw_separator('pixel_trans.gif', '11', '14');
      }


      $info_box_contents = array();
      $info_box_contents[] = array(array('params' => 'height="20" class="infoBoxHeading"',
                                         'text' => $left_corner),
                                   array('params' => 'width="100%" height="20" class="infoBoxHeading"',
                                         'text' => $contents[0]['text']),
                                   array('params' => 'height="14" class="infoBoxHeading" nowrap',
                                         'text' => $right_corner));


      $this->tableBox($info_box_contents, true);
    }
}
  }

Note that we don't only modify the method name here from infoBoxHeading to __construct, but we are also calling the parent construct via parent::__construct();



#20   bruyndoncx

bruyndoncx

    osCommerce Teenager

  • Members
  • 3,786 posts
  • Real Name:Carine Bruyndoncx
  • Gender:Female
  • Location:Belgium/ Antwerp/ Turnhout/ Arendonk

Posted 09 February 2016 - 00:12

just for the fun of it, tonight after midnight I changed version to php7 for a short while

I had a (custom) badly coded break statement in application top

I had to change this line from single to double quotes
if (!tep_session_is_registered("SESSION_USER_AGENT")) {

I also use apc caching and had to change the references to apc_xxx to apcu_xxx

Now, with the little tests I made on home page, categories page and product info page, it only gave me the construct warnings.

So overall pretty happy. Fix the constructors, I'll take some performance baseline numbers and readup on what potentially can go wrong before taking the plunge.

KEEP CALM AND CARRY ON
FYI Upgrade to the highest PHP version you can( PHP 5.5/5.6 or 7.1  and get big performance improvements for free)

But be aware php 5.5 is more strict about things.
UTF8-without BOM, no extra spaces allowed at the beginning or end of your php file, or your redirects wont work.
No double declarations of functions allowed - used to slip through the cracks ...

 

Find the most frequent unique errors to fix:

grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt