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

Delete temporary data when user cancels the transaction

I have a form on a website that users fill in to subscribe for a service and then a Paypal button for the users to pay for that service. Before sending the users to Paypal's website, I save the info that the user has submitted in temporary table in…
user765368
  • 19,590
  • 27
  • 96
  • 167
-1
votes
1 answer

Enforce Constant in a Class

How can I enforce constants in sub classes? For example: Class A implements B { } Class B implements I { } interface I { const bb = 'lr'; public function aa(); } Above code ensures class A & B Must have aa(), but is there any way I can…
Sheldon Cooper
  • 236
  • 4
  • 17
-1
votes
1 answer

Why not working phpinfo with php5.ini?

I try to run my phpinfo.php file with php5.ini, but still show me "Forbidden: You don't have permission to access /phpinfo.php on this server." error message. My site is working, only that phpinfo not... But, if rename it the php5.ini to php.ini the…
Marcell Nemeth
  • 97
  • 3
  • 4
  • 13
-1
votes
2 answers

session_status() is showing error because my server is not using PHP 5.4

it is saying this session_status is undefined function . can you tell me whats the replacement of it. in the given code
komal deep singh chahal
  • 1,229
  • 3
  • 13
  • 28
-1
votes
1 answer

Execute a PHP method one time

I call first time this route where I put in session 0 : public function userCaptcha(){ $_SESSION['isFacebookRegistration'] = 0; } After that I call another method which is executed 2 times by server : public function index() { …
TanGio
  • 766
  • 2
  • 12
  • 34
-1
votes
2 answers

Warning: simplexml_load_string() expects parameter 1 to be string, array given

I have this error :Warning: simplexml_load_string() expects parameter 1 to be string, object given in on line 195 and also this error: Fatal error: Call to a member function xpath() on a non-object in C:\wamp\ so my code in following : foreach (…
danoud
  • 7
  • 1
  • 3
-1
votes
1 answer

Fatal error:call to undefined method stdClass::xpath()

I have this XML: STANDARD N° ANCIEN DOSSIER And am running this PHP code: $xmljobreference = simplexml_load_string ($GetJobResult->JobReferences->JobReference->Title ); …
test
  • 19
  • 5
-1
votes
2 answers

Error in typing php info command flag

When I type: php -info I get this error message: Could not open input file: o I have php 5.4 installed. Trying to find info to configure IIS.
mmv_sat
  • 458
  • 8
  • 15
-1
votes
1 answer

How can I replace preg_replace with preg_replace_callback in PHP5.4?

I have a PHP page in which I am using following command:- $abc = preg_replace('/&#(\d+);/me', "chr(\\1)", $abc); Now I want to replace the above command with the "preg_replace_callback" function as preg_replace is deprecated in PHP 5.4 . How can I…
Gaurang
  • 371
  • 2
  • 4
  • 21
-1
votes
5 answers

SELECT query syntax in PHP

I'm self taught in PHP, but i'm afraid my syntax is off for the following MySQL query. $getPassword="SELECT password FROM $tbl_name WHERE username=$myusername"; $password=mysql_query($getPassword); Is the above registering $myusername as a string…
-1
votes
1 answer

How to turn a php array of unlimited(unknown) depth into a single array?

Array ( [72] => Array ( [id] => 70 [login] => test100 [parent_id] => 1 [type_id] => 1 [position] => 1 [user_id] => 72 [children] => Array …
Rustam
  • 249
  • 3
  • 11
-1
votes
3 answers

Why does this simple code yield 'Undefined variable: bar'

class A { protected $bar = 'bar'; public function foo() { echo $this->$bar; } } $a = new A(); $a->foo(); It's boggling my mind that this isn't working. I come from C++ and C# so it's likely something I don't understand about…
Nick Strupat
  • 4,928
  • 4
  • 44
  • 56
-1
votes
1 answer

Need simple php oop scope matrix

EDIT I've updated the question with actual code. Turns out it was not a scope issue but a stupid mistake on my part. While testing that all value were good I was really setting them to empty. After reading the answer below I realized I have the…
dmgd
  • 425
  • 4
  • 15
-2
votes
1 answer

Fetch vs FetchAll with mysql_query | PHP

I am aware that using mysql_query is terrible and the much better / preferred way of doing this is like so: PREFERRED $dbquery->fetch(PDO::FETCH_ASSOC)) BUT I HAVE TO However, working with a legacy system that uses mysql_query ... running into a…
ma77c
  • 1,052
  • 14
  • 31
-2
votes
2 answers

Handling multiple statements using ternary operators

I have tried like foreach ($this->Bay as $k => $obj) { $obj->{'BayId'} = ($obj->{'BayId'}=='') ? new MongoDB\BSON\ObjectID(); $obj->{'IsDeleted'} = "No"; : new MongoDB\BSON\ObjectID($obj->{'BayId'}); } if this condition…
Nida Amin
  • 735
  • 1
  • 8
  • 28
1 2 3
26
27