php-5.2

SoapClient error fallback in PHP

允我心安 提交于 2019-11-29 18:23:01
问题 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 'http://example.com/servlet/app/SomeService?wsdl' : failed to load external entity "http://example.com/servlet/app/SomeService?wsdl" Fatal errors in PHP, as far as I know, are not recoverable. Is there any way to fallback from this? Can this fatal error somehow be avoided? Edit: I should say that I

to use CRYPT_BLOWFISH on php 5.2 that doesn't support it

大城市里の小女人 提交于 2019-11-29 15:37:16
I am running my page on PHP 5.2 that does not support CRYPT_BLOWFISH but CRYPT_MD5 , and have heard that the blowfish is much more safer than md5. Since I am not the supervisor thing, I can not upgrade PHP to a version that supports it. Is there any hack for using CRYPT_BLOWFISH on PHP 5.2? and, $hash_key = crypt($something, '$2a$anySalt'); is pasting '$2a$' at the very first side correct? quite confused. P.s. If I use crypt() with CRYPT_BLOWFISH , will bcrypt work well in the crypt() function? You can use PHPASS which has fallbacks to support systems that don't support CRYPT_BLOWFISH.

Namespaces in php 5.2

☆樱花仙子☆ 提交于 2019-11-29 13:34:49
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 to use them with little changes to existing code? Namespaces are not supported prior to 5.3. There isn't really a way to adapt for them into 5.2 unfortunately. Namespaces are only available as of 5.3 At least in the case of classes, you can use the class_exists function to check if a class has already been defined with a like name within the global

Unexpected T_PAAMAYIM_NEKUDOTAYIM in PHP 5.2.x

大憨熊 提交于 2019-11-29 07:27:21
I'm having a hard time understanding why I'm getting an Unexpected T_PAAMAYIM_NEKUDOTAYIM error in the following code, which seems perfecly valid to me... class xpto { public static $id = null; public function __construct() { } public static function getMyID() { return self::$id; } } function instance($xpto = null) { static $result = null; if (is_null($result) === true) { $result = new xpto(); } if (is_object($result) === true) { $result::$id = strval($xpto); } return $result; } Output in PHP 5.3+: echo var_dump(instance()->getMyID()) . "\n"; // null echo var_dump(instance('dev')->getMyID()) .

How to Run PHP on IIS7.5 Express?

人盡茶涼 提交于 2019-11-29 03:21:05
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 the following PHP file: <? php echo "hello world"; ?> <html>HI</html> The output is HI but the PHP script doesn't run. I have followed the steps described in this article to install PHP: http://learn.iis.net/page.aspx/724/install-and-configure-php/ But can't proceed from step 10 onwards because IIS Express doesn't have an IIS Management Console MMC

PHP get_called_class() alternative

Deadly 提交于 2019-11-29 03:07:30
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.* } static function other_code() { //needs to know echo self::_get_class_name(); } } class Bar extends Foo { } class FooBar extends Foo { } Bar::other_code(); // i need 'Bar' FooBar::other_code(); // i need 'FooBar' This would work if I called the function get_called_class() -- however, this code is going to be run in PHP version 5.2.*, so that function is not available.

Creating DateTime from timestamp in PHP < 5.3

我怕爱的太早我们不能终老 提交于 2019-11-29 01:22:51
问题 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 DateTime("@$timeStamp"); 回答1: PHP 5 >= 5.3.0 $date = new DateTime(); $date->setTimestamp($timeStamp); Edit: Added correct PHP version for setTimestamp 回答2: Assuming you want the date and the time and not just the date as in the previous answer: $dtStr = date("c",

PHP Shorthand ternary operator “?:” Parse error unexpected “:”

寵の児 提交于 2019-11-29 01:04:22
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 all I thought I'd see if anyone knows anything about this as I've not used PHP for a while now. azat This is only available since PHP 5.3 The expression (expr1) ? (expr2) : (expr3) evaluates to expr2 if expr1 evaluates to TRUE , and expr3 if expr1 evaluates to FALSE . Since PHP 5.3, it is possible to leave out the middle part of the ternary operator.

How to use PHP Composer on HostGator

断了今生、忘了曾经 提交于 2019-11-28 16:18:19
问题 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 out of the box. Also, if you happen to have SSH access to your HG Shared account (You usually have to request it), you won't be able to run .PHAR files because the CLI version of PHP is also 5.2.2. Luckily, I got it to work... see below. 回答1: First

to use CRYPT_BLOWFISH on php 5.2 that doesn't support it

旧城冷巷雨未停 提交于 2019-11-28 10:20:31
问题 I am running my page on PHP 5.2 that does not support CRYPT_BLOWFISH but CRYPT_MD5 , and have heard that the blowfish is much more safer than md5. Since I am not the supervisor thing, I can not upgrade PHP to a version that supports it. Is there any hack for using CRYPT_BLOWFISH on PHP 5.2? and, $hash_key = crypt($something, '$2a$anySalt'); is pasting '$2a$' at the very first side correct? quite confused. P.s. If I use crypt() with CRYPT_BLOWFISH , will bcrypt work well in the crypt()