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

Get a substring up to the current match inside preg_replace_callback

I've simplified this question because it was getting quite long. Basically I want to get a substring of the $subject that goes from the start of $subject up to the current match the callback function is running on. Here is an example of some input…
Peter Gordon
  • 1,075
  • 1
  • 18
  • 38
0
votes
1 answer

Getting path of file on local machine without uploading in PHP

I have an html form with input as file.
Deepak S Rautela
  • 67
  • 1
  • 1
  • 13
0
votes
1 answer

Detecting mime Type (CSV) in PHP 5.4

How I detect mime Type (CSV) in PHP 5.4? Will I have enough simple PHP, do I need some library? Unfortunately, what I do not try, it's not working. Thanks in advance.
0
votes
3 answers

PHP Syntax Error in the Instance Declaration

i have a little syntax error which i'm not able to sort out, can anyone help ? Syntax: Config Class: Error:
Rishabh Jain
  • 110
  • 9
0
votes
2 answers

PHP - rename file with japanese characters

Why does the following code mistakenly renames 1.txt to 一.txt.txt and not 一.txt? rename('1.txt','一.txt');
dev4life
  • 10,785
  • 6
  • 60
  • 73
0
votes
1 answer

Delete session data after 2 min in php

I'm newbie in php and I have a question. So for example I have in session array a variable call game_url: $_SESSION['game_url'] = $_SERVER['HTTP_REFERER']; Is it possible to make a $_SESSION['game_url'] = ''; after 2 min after it has set? Any help…
TanGio
  • 766
  • 2
  • 12
  • 34
0
votes
1 answer

Set the HTTP content type response to “application/json” in php

I have a question. I have the folowing condition : You should return an HTTP 500 status code and more details about the error in the message body. Set the HTTP content type response to “application/json”.The error detail must be in JSON format as…
TanGio
  • 766
  • 2
  • 12
  • 34
0
votes
5 answers

PHP 5.4 associative array giving syntax error

I have a simple associative array declared like the following: static private $foo = [   16 => 'xyz',   7 => 'x',   8 => 'y',   9 => 'xy' ]; When I run a syntax check on this declaration, I get the following: Parse error:…
randombits
  • 47,058
  • 76
  • 251
  • 433
0
votes
1 answer

PHP 5.4 does not recognize parent constant

I migrated my cloud server, and after install all lamp stuff and clone my repository my php just does not recognizes the 'parent' constant. My log says. [Wed Jul 08 21:29:28 2015] [error] [client 186.223.169.223] PHP Notice: Use of undefined…
0
votes
0 answers

How to add status for each user?

I have two entity doctor and status, every doctor can add many status, I have this code: private function createCreateForm(statut $entity) { $form = $this->createForm(new statutType(), $entity, array( 'action' =>…
Aymen Rahal
  • 53
  • 1
  • 7
0
votes
2 answers

Setting a requirement of PHP 5.4 or higher

I need to require at least PHP 5.4 in my app. The current code detects only 5.0 or higher: $phpv=phpversion(); $t=explode(".", $phpv); if($t[0]>=5) $ok=1; else $ok=0; Typing 5.4 or 54 instead of 5 does not work properly.
0
votes
2 answers

How to create virtual folders using php?

I am using php with aws elasticbeanstalk. I want to create folder that accept this url : www.example.com/481818 where 481818 present an id that is changed. so i want to create file that accept every request form this structure…
david
  • 3,310
  • 7
  • 36
  • 59
0
votes
1 answer

Add on a percentage to a variable value in Smarty 2 template

I have assigned a variable in my Smarty 2 template. {assign var="real_count" value="{$store_summary|@count}"} {$real_count = settype ($real_count, 'integer')} My goal is to add on 65% to the value of $real_count. With the data i'm working with I…
crmpicco
  • 16,605
  • 26
  • 134
  • 210
0
votes
1 answer

php -- fetching data from a table and matching with another table to get data

I have two tables; dashboard_map_items and device_data_current. in dashboard_map_items I have two field, id and command and in device_data_current I have three field id, commands, current_value. Based on the id and commands in my dashboard_map_items…
AlbertSm
  • 105
  • 2
  • 2
  • 12
0
votes
0 answers

How to improve page loading time while processing more than two hundred thousand records?

I've an array with 251002 elements which are the child offices for a particular parent office. This is in the key value format, with an office id as key and office name as value. This is the format of the array. Array ( [1] => Test…
harry
  • 1,410
  • 3
  • 12
  • 31