Questions tagged [php-5.4]

PHP 5.4 is the successor to PHP 5.3. It was released on March 1, 2012. Use this tag for version-specific issues relating to specifically to PHP 5.4.

PHP 5.4 Changes:

  • Support for traits has been added.
  • Short array syntax has been added, e.g. $a = [1, 2, 3, 4]; or $a = ['one' => 1, 'two' => 2, 'three' => 3, 'four' => 4];.
  • Function array dereferencing has been added, e.g. foo()[0].
  • Closures now support $this.
  • <?= is now always available, regardless of the short_open_tag php.ini option.
  • Class member access on instantiation has been added, e.g. (new Foo)->bar().
  • Class::{expr}() syntax is now supported.
  • Binary number format has been added, e.g. 0b001001101.
  • Improved parse error messages and improved incompatible arguments warnings.
  • The session extension can now track the upload progress of files.
  • Built-in development web server in CLI mode.

See Migrating from PHP 5.3.x to PHP 5.4.x for more information.

Information

  • If you want to talk about PHP or if you have a question, you can come to Chat Room 11: PHP.
  • For global question on PHP, please use the generic tag:
402 questions
210
votes
11 answers

Set port for php artisan.php serve

How do we set a custom port for test server? Normally when we do php artisan serve the folder gets served as : localhost:8000 How do could we access one folder as: localhost:8080 I want to access two different development sites on my localhost.
maan81
  • 3,469
  • 8
  • 36
  • 53
45
votes
7 answers

How to fix the session_register() deprecated issue?

How to fix the session_register() deprecated problem in PHP 5.3
DEVOPS
  • 18,190
  • 34
  • 95
  • 118
43
votes
3 answers

PHP built in server and .htaccess mod rewrites

Does PHP's built in server not make use of .htaccess? Makes sense, I suppose, as it isn't relying upon Apache(?). Anyway, is it possible to tell the server to make use of these files - can it handle URL rewrites? I have some projects in frameworks…
Martyn
  • 6,031
  • 12
  • 55
  • 121
31
votes
5 answers

How to format var_export to php5.4 array syntax

There are lots of questions and answers around the subject of valid php syntax from var outputs, what I am looking for is a quick and clean way of getting the output of var_export to use valid php5.4 array syntax. Given $arr = [ 'key' =>…
designermonkey
  • 1,078
  • 2
  • 16
  • 28
17
votes
1 answer

Why do strings behave like an array in PHP 5.3?

I have this code: $tierHosts['host'] = isset($host['name']) ? $host['name'] : $host; It's working fine in PHP 5.5, but in PHP 5.3 the condition returns true while $host contains a string like pjba01. It returns the first letter of…
Ritesh
  • 4,720
  • 6
  • 27
  • 41
16
votes
2 answers

PHP Try Catch for Entire Class

Simple question but can't seem to find the answer. If I have a php class, is it possible to register an exception handler for the whole class? The reason I want to do this is that my class uses objects that are part of my domain model. These…
GWed
  • 15,167
  • 5
  • 62
  • 99
16
votes
8 answers

How to run a webphar PHP file from built-in PHP 5.4 webserver?

As per title, I created a very simple test phar. I'd like to test it with the built-in webserver(PHP 5.4) but it seems impossible. php -S localhost:80 /path/to/myphar.php Result: blank page (in the phar front controller is index.php doing some HTML…
gremo
  • 47,186
  • 75
  • 257
  • 421
15
votes
3 answers

How do I run PHP's built-in web server in the background?

I've written a PHP CLI script that executes on a Continuous Integration environment. One of the things it does is it runs Protractor tests. My plan was to get the built-in PHP 5.4's built-in web server to run in the background: php -S localhost:9000…
Housni
  • 963
  • 1
  • 10
  • 23
12
votes
3 answers

Need XAMPP with PHP 5.4 version - windows

I have come across a situation where I need XAMPP with PHP 5.4 version. I will install it on windows server 2003. May I know the repository where I can find all the older versions of xampp for windows? Thanks!
Danyal Sandeelo
  • 12,196
  • 10
  • 47
  • 78
12
votes
4 answers

How to bind $this to a closure that is passed as a method parameter in PHP 5.4?

Is there any way to bind $this to a closure that is passed as a parameter? I read and reread everything I could find in manual or over the internet, but no one mentions this behaviour, except this blog…
unknown.bird
  • 155
  • 1
  • 7
9
votes
1 answer

Where can I get MongoDB PHP driver for PHP 5.4 precompiled for Windows?

Where can I get mongo php driver for PHP 5.4? For windows vc9 not thread safe.
StXh
  • 1,856
  • 1
  • 13
  • 16
9
votes
1 answer

imagecrop() alternative for PHP < 5.5

A simple question motivated by a curiosity, with probably a complex answer: Is it possible to emulate the new PHP 5.5 imagecrop() in earlier versions, like 5.4, by combining other GD functions? Awn.. But without the imagecrop() black line bug,…
user753531
8
votes
2 answers

What is the difference between E_STRICT and E_ALL in PHP 5.4?

In PHP 5.4, what is the difference between using E_STRICT and E_ALL ? Are both the same?
jlocker
  • 1,478
  • 1
  • 12
  • 23
8
votes
1 answer

Converting indexed array to normal or simple array

I am trying to convert indexed array to normal array. Basically what get is: Array ( [0] => 14 [1] => 19 [2] => 20 ) And I need is: Array(14,19,20); I tried over Google but not information found. I think this kind of function isn't available in…
Capripio
  • 474
  • 11
  • 21
7
votes
2 answers

Is is_dir() unreliable, or are there race conditions that can be mitigated here?

At work, I've inherited a web application that has a file upload process. Part of this process occasionally (once every two weeks or so) triggers the following error: PHP Warning: mkdir(): File exists in {{{file_path_name_redacted}}} on line…
e_i_pi
  • 4,590
  • 4
  • 27
  • 45
1
2 3
26 27