php-5.2

Class 'ZipArchive' not found error while using PHPExcel

隐身守侯 提交于 2019-12-03 17:11:58
When I use PHPExcel on a new server, I faced the error "Class 'ZipArchive' not found" and it seems to be blocked by my hosting service provider. Can't I use PHPExcel on the server without Zip support? PHP 5.2.8 is installed on this server but I can't use a basic PHP source code for PHPExcel. Any help will be appreciated, thanks. Mark Baker Certain spreadsheet file formats, such as OfficeOpenXML used as the default format by Excel 2007 and above, require ZipArchive. In most recent versions of PHP, ZipArchive is always available, but prior to PHP 5.3 it needed to be manually installed on some

How to find unique values in array

混江龙づ霸主 提交于 2019-12-02 15:01:17
问题 Here i want to find unique values,so i am writing code like this but i can't get answer,for me don't want to array format.i want only string <?php $array = array("kani","yuvi","raja","kani","mahi","yuvi") ; $unique_array = array(); // unique array $duplicate_array = array(); // duplicate array foreach ($array as $key=>$value){ if(!in_array($value,$unique_array)){ $unique_array[$key] = $value; }else{ $duplicate_array[$key] = $value; } } echo "unique values are:-<br/>"; echo "<pre/>";print_r(

How to find unique values in array

徘徊边缘 提交于 2019-12-02 11:23:23
Here i want to find unique values,so i am writing code like this but i can't get answer,for me don't want to array format.i want only string <?php $array = array("kani","yuvi","raja","kani","mahi","yuvi") ; $unique_array = array(); // unique array $duplicate_array = array(); // duplicate array foreach ($array as $key=>$value){ if(!in_array($value,$unique_array)){ $unique_array[$key] = $value; }else{ $duplicate_array[$key] = $value; } } echo "unique values are:-<br/>"; echo "<pre/>";print_r($unique_array); echo "duplicate values are:-<br/>"; echo "<pre/>";print_r($duplicate_array); ?> You can

“unexpected T_PAAMAYIM_NEKUDOTAYIM” on one computer but not another with PHP 5

萝らか妹 提交于 2019-12-02 04:39:10
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) a workaround or 2) some other reason this is happening? One workaround will be call_user_func(array($productModule, "load"), Phlex_Db_Order::Asc('name')); or, according to the manual since 5.2.3: call_user_func($productModule."::load", Phlex_Db_Order::Asc('name'));

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

巧了我就是萌 提交于 2019-12-01 04:51:43
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 it gives T_PAAMAYIM_NEKUDOTAYIM . $> cat test.php <? interface strategyInterface { public function execute(); public function getLog(); public static function getFormatString(); } class strategyA implements strategyInterface { public function execute() {} public

PHP date_parse_from_format( ) alternative in PHP 5.2

江枫思渺然 提交于 2019-11-30 15:25:56
Since date_parse_from_format( ) is available only in PHP 5.3, I need to write a function that mimics its behaviour in PHP 5.2. Is it possible to write this function for PHP 5.2 and make it work exactly the same way that it does in PHP 5.3? Example: For this input: <?php $date = "6.1.2009 13:00+01:00"; print_r(date_parse_from_format("j.n.Y H:iP", $date)); ?> I need this output: Array ( [year] => 2009 [month] => 1 [day] => 6 [hour] => 13 [minute] => 0 [second] => 0 [fraction] => [warning_count] => 0 [warnings] => Array ( ) [error_count] => 0 [errors] => Array ( ) [is_localtime] => 1 [zone_type]

SoapClient error fallback in PHP

对着背影说爱祢 提交于 2019-11-30 12:56:56
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 am running on PHP 5.2, if it makes any difference. This has already been discussed : https://bugs

Unexpected T_PAAMAYIM_NEKUDOTAYIM in PHP 5.2.x

柔情痞子 提交于 2019-11-30 08:42:04
问题 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

Creating DateTime from timestamp in PHP < 5.3

北城余情 提交于 2019-11-30 04:37:07
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"); Dawid Ohia PHP 5 >= 5.3.0 $date = new DateTime(); $date->setTimestamp($timeStamp); Edit: Added correct PHP version for setTimestamp Assuming you want the date and the time and not just the date as in the previous answer: $dtStr = date("c", $timeStamp); $date = new DateTime($dtStr); Seems pretty silly to have to do that though. It's not working

How to use PHP Composer on HostGator

为君一笑 提交于 2019-11-29 20:19:13
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. First off, you can enable PHP 5.3 on HostGator on a directory level basis. Simply add the following line to the