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

How can I connect my legacy PHP application to MySQL v8?

I have a legacy PHP forum that I'd like to make available read-only for archive purposes. I've managed to get it running in a docker container using php 5.4, and I have it connecting just fine to a MySQL 5 container. When I switch to using MySQL 8,…
Tobias Fünke
  • 2,034
  • 3
  • 24
  • 38
3
votes
2 answers

PHP 5.4.17 alternative for the "... operator"

I was wondering if someone may know an alternative to the PHP 5.6.x and higher ... operator (or splat operator I believe its called). What i'm currently doing in my PHP 7 version is: $this->callAction( ...explode('@',…
Tom Schmitz
  • 62
  • 2
  • 7
3
votes
2 answers

How to get parameter type in reflected class method (PHP 5.x)?

I'm trying to get type $bar variable. getMethods() as $method) { foreach ($method->getParameters() as…
Kirby
  • 2,847
  • 2
  • 32
  • 42
3
votes
1 answer

Better way to convert array of objects in PHP to associative array to populate a HTML select

Say I have an array of objects with the following structure: Array ( [0] => stdClass Object ( [category_id] => 5 [category_title] => Meetings [category_slug] => meetings [category_summary] => This is the…
geoffs3310
  • 5,599
  • 11
  • 51
  • 104
3
votes
4 answers

file_get_contents() returns literal 'Not Found' instead of boolean

This is the code I am using: It prints Not Found instead of something.…
Jahid
  • 21,542
  • 10
  • 90
  • 108
3
votes
2 answers

Paypal html button custom field limit

there is a limit of 256 characters on the custom field for a Paypal html button. Is there a way to increase that limit or are there other fields that I can user (like custom1, custom2, other), etc... Thank you
user765368
  • 19,590
  • 27
  • 96
  • 167
3
votes
1 answer

How does PHP interpret and evaluate function and anonymous function when passed as an argument?

I am a experience developer in PHP, I already know what is a function and what is a anonymous function. I also know what is the use of anonymous function and functions in PHP or in other languages. I also know the difference between function and…
Chetan Ameta
  • 7,696
  • 3
  • 29
  • 44
3
votes
1 answer

Constant in PHP class and "static" keyword

Please consider this code: class App { const ALERT_ERROR=1; const ALERT_WARN=2; const ALERT_INFO=3; public static function alert($title,$type=ALERT_ERROR) { switch ($type){ …
Tobia
  • 9,165
  • 28
  • 114
  • 219
3
votes
1 answer

How to do an IMAP search based on "Delivered-To" header (or how to use the gmail imap extension?)

I need to search gmail messages (google apps for work) via imap/php. However, imap_search criterias are not enough to catch the messages in question. The code I use looks like this: $imap = imap_open("{imap.gmail.com:993/imap/ssl}Label1/label2",…
TheDude
  • 3,045
  • 4
  • 46
  • 95
3
votes
0 answers

502 Bad Gateway error on nginx

I have a problem on my nginx server, so I tried to update php from 5.3 to 5.5 with this commands: add-apt-repository ppa:ondrej/php5 sudo apt-get update sudo apt-get install php5 Earlier work all right but before I make this update I get 502 Bad…
user3784219
  • 31
  • 1
  • 3
3
votes
3 answers

Datatables footer error: Uncaught TypeError: Cannot set property 'nTf' of undefined

I am facing problem related to datatables. I have a large number of records (45,000 +). So I am using datatables with "Server Side " coding. The issue is this, its showing the following error in the below code is: ERROR: Uncaught TypeError: Cannot…
Bilal Yousaf
  • 31
  • 1
  • 5
3
votes
1 answer

Warning: ftp_put() expects parameter 1 to be resource, boolean given in

I am trying to do a form that upload a few fields, and 3 images. The images will be uploaded via FTP, there is a problem connecting to ftp with ftp_connect() when the php is uploaded to remote server. It couldn't connect to server when the php is in…
Benyaman
  • 451
  • 2
  • 10
  • 25
3
votes
2 answers

Dreamweaver CS5 code hinting and syntax errors with PHP 5.4

I have done some research but have not found something that fits my scenario exactly. I am using Dreamweaver CS5 with PHP files and Dreamweaver alerts me that there is an error in my code with this…
amaster
  • 1,915
  • 5
  • 25
  • 51
3
votes
4 answers

PHP script to restore a database into another empty database

This question might seem a duplicate, However i tried all the examples to restore my database but none seems to work for me. I am trying to run a script that will restore my backup sql file to new database. I tried these lines to restore my…
Abdul Hamid
  • 3,222
  • 3
  • 24
  • 31
3
votes
2 answers

How to create random unique alphanumeric string in PHP

I have the following code that lets a user register his/her email on a website with a password, and returns them a unique pin.
alias51
  • 8,178
  • 22
  • 94
  • 166