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
2
votes
1 answer

Default callable in function definition in php 7

I have a function with 2 arguments: a string, and a callable. I want the callable to be optional. See below. function saySomething($str, $callback){ echo $str; $res = false; if(is_callable($callback)){ $res = $callback(); …
Julian
  • 4,396
  • 5
  • 39
  • 51
2
votes
2 answers

Upgrade symfony 2.8 or php 5.4 first?

I'll be working soon on a project and I just wanted to ask this before. The project is on symfony 2.8 with php 5.4. The goal is to upgrade symfony to 3.4 (maybe 4.x later) and php to 7.x (probably 7.2). So here is my question : is there a better…
2
votes
0 answers

Why does the output of $HTTP_RAW_POST_DATA and file_get_contents("php://input") differ?

I'm fairly new to PHP and in the process of updating a system from PHP5 to PHP7. $HTTP_RAW_POST_DATA is deprecated in PHP7 and I had read that file_get_contents("php://input") was it's equivocal replacement. I have tested them against each other…
ben-ledi
  • 124
  • 5
2
votes
4 answers

Why Traits cannot be instantiated directly?

While testing for traits in PHP I was a bit confused why traits were introduced. I did some minor experiment. First I called trait methods directly in a class
Amit Ray
  • 3,445
  • 2
  • 19
  • 35
2
votes
3 answers

Sum the elements of an array key in a multidimensional array

This is my array [Company] => Array ( [0] => Array ( [date] => 2016-05-28 [revenue] => 55 ) [1] => Array ( …
2
votes
1 answer

Is Unit Test Applicable Here?

public function addPic($loggedInId,$PicId){ $chatCoverPhotoObj = new COVER_PHOTO(); $out = $chatCoverPhotoObj->add($loggedInId,$PicId); if($out) return true; return false; } Above sample code is…
user6223764
2
votes
2 answers

Symfony2 on php 5.4

I need to change my Symfony2 website to a new server and I've noticed that the new server is currently installed php 5.4, when Symfony2 need a minimum of 5.5.9. By doing some tests they are taking place some errors like: php.CRITICAL: Fatal Parse…
abdiel
  • 2,078
  • 16
  • 24
2
votes
2 answers

Set an exception handler in a class for a specific exception subclass

I have a simple class in a PHP project that uses something like the following in its constructor: @set_exception_handler(array($this, 'exception_handler')); The problem is, it's catching exceptions in global scope, eg: exceptions that are…
randombits
  • 47,058
  • 76
  • 251
  • 433
2
votes
2 answers

MYSQL Syntax error in php but sql is valid

I'm trying to start a transaction is mysql and insert data into the database. The database source sql can be found on github here. Here is the error: Error: START TRANSACTION; INSERT INTO Books(Title, PublicationDate, PurchaseDate, Description,…
Jacob Wilson
  • 430
  • 1
  • 5
  • 12
2
votes
1 answer

PHP JSON Extension

I have already seen posts mentioning this on StackOverflow, but there is something I'm not understanding. The json module for php is installed using apt-get install php5-json. I read from the PHP site that the json extension is no longer supported…
White Lotus
  • 353
  • 2
  • 6
  • 16
2
votes
2 answers

Not able to install xdebug on Ubuntu 12.04 LTS

I am not able to install xdebug on Ubuntu 12.04 LTS. The instruction I received from xdebug wizard are as follows:- Download xdebug-2.4.0beta1.tgz Unpack the downloaded file with tar -xvzf xdebug-2.4.0beta1.tgz Run: cd xdebug-2.4.0beta1 Run:…
tuk
  • 5,941
  • 14
  • 79
  • 162
2
votes
2 answers

mysql_real_escape_string not work in php 5.4.44

I am runing PHP Version 5.4.44 on my website and try to us mysql_real_escape_string but it does not give me any thing .mysql_real_escape_string works just fine in localhost on my computer.Example Code
Usman Mustafa
  • 77
  • 1
  • 8
2
votes
2 answers

What version of PHP is Symfony using?

I have been struggling with this for a few hours now. I am running CentOS 6.6. A few hours ago I was having issues with a Symfony project that required PHP 5.4+ because of some libraries required. So I installed version 5.4 and I used to have PHP…
Leo
  • 834
  • 8
  • 14
2
votes
0 answers

Laravel Eloquent Query Building

My current query is select * from `users` where `group_id` = 1 and ((select count(*) from `works` inner join `user_work` on `works`.`id` = `user_work`.`work_id` where `user_work`.`user_id` = `users`.`id` and `work_duration_id` >= 3) >= 1) For this…
Dixit Sourav
  • 350
  • 1
  • 3
  • 10
2
votes
1 answer

Not able to access parent members

I have a configuration file where I am defining my database configuration. My configuration file is I have a config class where I…
Bushra Shahid
  • 781
  • 7
  • 20