php52

PHP: variable name as class instance

Hey guys, Im having a problem with using a variable as the class name when calling a static function within the class. My code is as follows: class test { static function getInstance() { return new test(); } } $className = "test"; $test = $className::getInstance(); Ive got to define the class name to a variable a...

Xdebug with PHP 5.2 on 64-bit Windows 7?

I would like to install Xdebug (http://xdebug.org/) on my 64 bit Windows 7 machine to debug Drupal code running on PHP 5.2. The Xdebug download page does not provide a download for a 64 bit version compatible with PHP 5.2. Many Drupal modules are not compatible with PHP 5.3, so it is not an option to switch to a later version of PHP. W...

How to update php-imap on Centos 5.4?

phpinfo: imap IMAP c-Client Version 2004 SSL Support enabled Kerberos Support enabled But imap_header() was crashed on this version library. http://bugs.php.net/bug.php?id=20254 and other Please, help me to update libc-client and php-imap on Centos 5.4 (php 5.2) ...

Packaging PHPUnit tests as a PHAR archive?

Is it possible to package PHPUnit tests as a PHAR archive, and run them using phpunit? I've created a .phar with the follow script: <?php $cPhar = new Phar('mytests-archive.phar', 0); $cPhar->addFile('mytest.php'); $sStub = <<<ENDSTUB #! /usr/bin/php <?php Phar::mapPhar('mytest-archive.phar'); require 'phar://mytests-archive.phar/myte...

PHP help with error

Hi, I am working on a Zend project and it has been well over 12 months since I touched Zend, I am getting an error on one of my functions, and I cannot work out why, I think it may be down to the site being originally built in an earlier version of PHP (5.2) and I am now running 5.3. The function looks like this, public function add...

Troubles with DateTime and PHP 5.2

I'm attempting to use the PHP DateTime class on a Solaris server with PHP 5.2.6, while testing on my local Windows box running PHP 5.3. Here is the code: <?php try { $dt = new DateTime('2009-10-08'); $dt->setDate(2009,10,8); print_r($dt); }catch (Exception $e) { echo $e->getMessage(); } On the test server, things work flawlessly,...

Catch a PHP Object Instantiation Error

It's really irking me that PHP considers the failure to instantiate an object a Fatal Error (which can't be caught) for the application as a whole. I have set of classes that aren't strictly necessary for my application to function--they're really a convenience. I have a factory object that attempts to instantiate the class variant that'...

Can Symfony simply reload a page request?

I have an app that receives a request from another app. It detects a value on the query string, checks that value against a cached value and, if they don't match, it needs to clear its cache and reload the page (establishing a new cache). Unfortunately, I can't find a way to tell Symfony to redirect to the current page in exactly the sam...

Is there a Symfony callback at the termination of a session?

I have an application that is authenticating against an external server in a filter. In that filter, I'm trying to set a couple of session attributes on the user by using Symfony's setAttribute() method: $this->getContext()->getUser()->setAttribute( 'myAttribute', 'myValue' ); What I'm finding is that, if I dump $_SESSION immediately ...

alternative to json_decode before PHP 5.2

Is there a simple alternative to using json_decode function in php versions prior to 5.2? I am feeling lazy at this time of night and can't be bothered to update php yet. Cheers. ...

How to programatically change every method to return $this (except predefined list)?

I have a class: class Module { public function a(...params...) { //do something, doesn't return anything } public function b(...params...) { //do something, doesn't return anything } public function c(...params...) { //do something, doesn't return anything } public function get...

How to calculate person's age in months+days in PHP 5.2 ?

I have asked this question before and accepted the answer but now I found that the php version on our server is 5.2 and DateTime::diff() is not working on that. I want to calculate person's age in months plus days using date of birth and a given date. Date Format Input: Y-m-d (example: 1986-08-23) Output: 5 months and 20 days old. 15...

convert unix timestmp to date

how to I convert a unix timestamp 1280214000 to human readable date? thanks ...

Php cgi installation on Windows 2008 r2

Hi all, i am trying to install php5.2.14 version to configure to IIS CGI in windows 2008 r2. but i am getting the error http 502.2 bad gateway. Can any one tell me how to overcome this? thanks in advance ...

PDO maturity in PHP 5.2.13

How mature is PDO for PHP 5.2.13 for a serious project? (By serious I mean a script that is going to be sold and deployed in different platforms and environments. Something not serious would be for testing or developing, in this case) Currently, most host companies are running PHP 5.2.13 and adoption for 5.3.x seems too far away... S...

preg_replace exact opposite [php 5.2.10]

I'm looking to do something like get the opposite match from this line: $input = "21.asdf*234true;asdf0--11" $_BOOL_ ="/(true|false)/i"; $output = preg_replace($_BOOL_, '', $input); //Result: "21.asdf*234;asdf0--11" //Desired result: "true" Which ofcourse in php 5.3 is $output = preg_filter($_BOOL_, '', $input); But I'm on 5.2, and...

"unexpected T_PAAMAYIM_NEKUDOTAYIM" on one computer but not another with PHP 5

My local computer runs PHP 5.3.2, while my server runs 5.2.5. I get Parse error: syntax error, unexpected T_PAAMAYIM_NEKUDOTAYIM with $productsIterator = $productModule::load(Phlex_Db_Order::Asc('name')); I assume the error happens because PHP 5.2.5 doesn't support $stringClassName::methodName() syntax. Does anyone know either 1) ...

PHP 5.2 and 5.3 together

I have XAMPP with PHP 5.2, but my new projects need PHP 5.3 How to have PHP 5.2 and 5.3 together? I have winXP. ...

Can't call static method from class as variable name?

I'm using php 5.2.6. I have a strategy pattern, and the strategies have a static method. In the class that actually implements one of the strategies, it gets the name of the strategy class to instantiate. However, I wanted to call one of the static methods before instantiation, like this: $strNameOfStrategyClass::staticMethod(); but i...

What's the best way to handle dates and times in PHP prior to 5.3?

Well, found out that I built a relatively large program built on top of DateTime, only to find most of what I used there got added in PHP 5.3. The server I have to deploy to does not run 5.3. (And it's a Ubuntu Hardy (8.04) box which doesn't have a 5.3 package in the main repo, and I'm not allowed to install anything not in the main repo...