Questions tagged [php-5.2]

PHP 5.2 (now past End of Life) is the successor to PHP 5.1. It was released on November 2, 2006. Use this tag for version-specific issues relating to specifically to PHP 5.2.

PHP is a widely-used, general-purpose scripting language designed specifically for web development, though it has since been extended to other applications too. PHP is the most popular language for web development, powering over 20 million websites.

Note that support for PHP 5.2 has been officially discontinued. There are no externally supported versions of 5.2 (i.e. backported security fixes) so it is highly recommended you upgrade to a supported version.

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:
247 questions
155
votes
9 answers

Get current domain

I have my site on the server http://www.myserver.uk.com. On this server I have two domains: one.com and two.com I would like to get the current domain using PHP, but if I use $_SERVER['HTTP_HOST'] then it is showing me myserver.uk.com instead…
Tony Evyght
  • 1,885
  • 5
  • 18
  • 19
63
votes
7 answers

How to get protected property of object in PHP

I have a object having some protected property that I want to get and set. The object looks like Fields_Form_Element_Location Object ( [helper] => formText [_allowEmpty:protected] => 1 [_autoInsertNotEmptyValidator:protected] =>…
Awais Qarni
  • 14,876
  • 22
  • 72
  • 134
63
votes
10 answers

Assigning the return value of new by reference is deprecated

I've just got an error. When I try to assign an object like this: $obj_md = new MDB2(); The error I get is "Assigning the return value of new by reference is deprecated". Actually I've been looking for a solution but the only one I've seen is just…
José M. Gilgado
  • 1,198
  • 3
  • 13
  • 20
60
votes
4 answers

Creating DateTime from timestamp in PHP < 5.3

How do you create a DateTime from timestamp in versions less than < 5.3? In 5.3 it would be: $date = DateTime::createFromFormat('U', $timeStamp); The DateTime constructor wants a string, but this didn't work for me $date = new…
Yarin
  • 144,097
  • 139
  • 361
  • 489
33
votes
2 answers

PHP Shorthand ternary operator "?:" Parse error unexpected ":"

I've just uploaded some old PHP files to a new server and am getting parse errors (Unexpected ':') on shorthand ternary ops. eg: $y = $x ?: "Some default"; php version is 5.2.16 The code is littered with these shorthand ?:, so before changing them…
Paul Kersey
  • 437
  • 1
  • 5
  • 10
33
votes
3 answers

How to use PHP Composer on HostGator

I recently decided to start a project in Zend Framework 2 and was having trouble getting it to run on a HostGator shared server. By default, HostGator's shared servers run in PHP 5.2.2 and if you upload the ZF2 Skeleton Application, it will not run…
Zach
  • 1,252
  • 2
  • 11
  • 17
26
votes
10 answers

What can use for DateTime::diff() for PHP 5.2?

Is there any function equivalent to DateTime::diff() in PHP 5.2? My local server is PHP 5.3 and using DateTime::diff(). then I found that my live site uses PHP 5.2 and gives an error. Fatal error: Call to undefined method DateTime::diff() in…
shin
  • 28,830
  • 62
  • 170
  • 248
19
votes
9 answers

PHP get_called_class() alternative

I've got an Abstract PHP superclass, which contains code that needs to know which subclass its running under. class Foo { static function _get_class_name() { return get_called_class(); //works in PHP 5.3.*, but not in PHP 5.2.* …
Kenneth Ballenegger
  • 2,900
  • 2
  • 17
  • 25
16
votes
3 answers

How to Run PHP on IIS7.5 Express?

I have Win XP SP3 and have installed IIS7.5 Express and want to run PHP on it. I am able to run simple HTML code on the server, I am able to start and stop the server by running iisservices.exe, but I am not able to run php scripts on it. If I have…
Saurabh
  • 161
  • 1
  • 1
  • 3
12
votes
5 answers

Namespaces in php 5.2

I've done little web using namespaces. I have it in my computer and i'm about to moving it to free hosting that uses php 5.2. Syntax highlighter for php 5.2 interprets them as errors. Are namespaces supported by php 5.2? If not is there any way how…
kravemir
  • 9,380
  • 15
  • 54
  • 99
12
votes
4 answers

How Significant Is PHP Function Call Overhead?

I'm relatively new to PHP and slowly learning the idiosyncrasies specific to the language. One thing I get dinged by a lot is that I (so I'm told) use too many function calls and am generally asked to do things to work around them. Here's two…
Josh Johnson
  • 9,458
  • 11
  • 56
  • 81
11
votes
4 answers

php callback function in class

for some reasons, our hosting company used PHP 5.2 and doesn't even have mysqli and PDO pre-installed. I have no choice but to rewrite some part of my code to make it 5.2 compatible. so, here is my question: In PHP 5.2 Anonymous function is not…
tom91136
  • 7,875
  • 11
  • 53
  • 72
10
votes
2 answers

SoapClient error fallback in PHP

In PHP, if you try to instantiate a new SoapClient, and the WSDL is not accessible (server down or whatever), a PHP fatal error is thrown: Fatal error: SOAP-ERROR: Parsing WSDL: Couldn't load from …
Yuval Adam
  • 149,388
  • 85
  • 287
  • 384
10
votes
6 answers

php dateTime::createFromFormat in 5.2?

I have been developing on php 5.3. However our production server is 5.2.6. I have been using $schedule = '31/03/2011 01:22 pm'; // example input if (empty($schedule)) $schedule = date('Y-m-d H:i:s'); else { $schedule =…
Hailwood
  • 79,753
  • 103
  • 257
  • 412
10
votes
2 answers

Parse error: syntax error, unexpected '[', expecting ')'

I have this linecode $media = $dc->thumbnail->attributes()['url']; runs fine on my local (WAMP) php 5.4.3 but when i host it on my server cpanel then it gives this error Parse error: syntax error, unexpected '[', expecting ')' the php version on…
1Mayur
  • 3,269
  • 5
  • 36
  • 63
1
2 3
16 17