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
1
vote
0 answers

PHP: store a global information so it can be accessed by all other users?

Is there a way that PHP can track and keep a data for what page is being accessed and then this piece of data can be opened/ accessed by all other computers/ users? For instance, when I am inside my CMS and editing a page called 'home' then I want…
Run
  • 54,938
  • 169
  • 450
  • 748
1
vote
3 answers

PHP: get a result from a chaining method from extended classes?

I am trying to get a result from a chaining method from extended classes below, class Base { protected $id; public function setId($input) { $this->id = $input; return $this; } } class PageChildren extends Base { …
Run
  • 54,938
  • 169
  • 450
  • 748
1
vote
2 answers

PHP: destroy $_COOKIES only but not $_SESSION?

I just want to destroy all $_COOKIES info but not the info/ data in $_SESSION, so I use this code below, but it destroy all my $_SESSION data as well which is not what I want, // Destroy all cookies. foreach ( $_COOKIE as $key => $value ){ …
Run
  • 54,938
  • 169
  • 450
  • 748
1
vote
6 answers

PHP: How to trim off everything before certain keywords in strings?

I have these type of results from a loop function, C:/wamp/www/xxx/core/page/ C:/wamp/www/xxx/local/page/ But how can I trim off anything before core or local, so I get these only, core/page/ local/page/ I use strstr, but I think it search for a…
Run
  • 54,938
  • 169
  • 450
  • 748
1
vote
1 answer

PHP recursiveIteratorIterator: get the sub directories only?

I just want to list the sub dirs in the main dirs by using RecursiveIteratorIterator, $array_directories = array( 'core/controller/', 'core/model/', 'core/helper/' ); foreach($array_directories as $path_directory){ $iterator = new…
Run
  • 54,938
  • 169
  • 450
  • 748
1
vote
1 answer

How to allow public or private downloads of static files with PHP 5.4 Web Server?

I'm using Silex/Symfony 2 framework. Users may upload either private (web/assets/uploads/*.*) and public documents (app/uploads/*.*), uploaded file is moved to the right folder with a sanitized name, and a new record is created in the upload…
gremo
  • 47,186
  • 75
  • 257
  • 421
1
vote
1 answer

PHP SimpleXML Load File with Null elements

I have the following XML file called 'cookie_domain.xml' with the contents: cookie_domain Cookie Domain Sessions
Russell Seymour
  • 1,333
  • 1
  • 16
  • 35
1
vote
3 answers

PHP (HTML5) based Windows Software

Is it possible to make from a HTML5-APP (PHP,SQLITE,HTML,CSS,JS) a installable Windows Software in c#? The software must start PHP (5.4), and must just load the document-root in the webbrowser object. In theory it should work without problems. But…
mr_app
  • 1,292
  • 2
  • 16
  • 37
1
vote
3 answers

PHP Class: writing functions inside an object?

I wonder if this below is possible in php class object, just as I would do in javascript (jquery). In jquery, I would do, (function($){ var methods = { init : function( options ) { // I write the function here... }, …
Run
  • 54,938
  • 169
  • 450
  • 748
1
vote
0 answers

My PHP script is just exiting when encountering a strict error. i.e. the strict errors are not being displayed

My problem is this: I have errors in my PHP code but they're not being displayed. My script is just terminating when the error is encountered. After much poking, I've deduced that the errors are strict mode errors but I'm having trouble fixing them…
1
vote
1 answer

DateTime is one month off when formatting?

I ran into this, and thought my server was crazy, but after testing it in Codepad I run into the same results. After using Datetime to try and process my date stamp I end up one day and one month OFF my original date after trying to format back to a…
ehime
  • 8,025
  • 14
  • 51
  • 110
1
vote
1 answer

PHP Memory Allocation and Deallocation

So, I am running a long-running script that is dealing with memory sensitive data (large amounts of it). I (think) I am doing a good job of properly destroying large objects throughout the long running process, to save memory. I have a log that…
Kovo
  • 1,687
  • 14
  • 19
1
vote
3 answers

Using while() and continue in PHP

I am learning PHP and trying to use the while and continue expressions correctly. I have a script that creates a 6 digit PIN, and I want to ensure that it is unique, otherwise I want to generate another PIN. while(1) { $pin =…
alias51
  • 8,178
  • 22
  • 94
  • 166
0
votes
1 answer

Containerized PHP application sessions directory is empty

We are migrating a PHP website from an old host to a container. The old code runs on VM directly, now we built a container that facilitate the PHP website. Both old and new PHP website run on top of apache httpd with php version 5.4.16. However,…
user1763590
  • 117
  • 2
  • 14
0
votes
0 answers

Unable to connect to MySQL from php using AdoDB

We're trying to connect MySQL v8.0 from php 5.4, using AdoDB (V5.05 11 July 2008). Upon connecting, we're getting the following error: Server sent charset unknown to the client. Please, report to the developers The above setup is required because we…