php-5.2

Class 'ZipArchive' not found error while using PHPExcel

半世苍凉 提交于 2019-12-21 05:34:12
问题 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. 回答1: 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,

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

我的未来我决定 提交于 2019-12-19 06:14:27
问题 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

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

你离开我真会死。 提交于 2019-12-17 04:32:12
问题 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 /var/www/some/other/dir/web/daikon/modules/projects/views/admin/log/admin_log_list.php on line 40 The PHP code: foreach ($logs as $key => $list){ ... // show date in European way dd-mm-yyyy not in MySQL way yyyy-mm-dd $newdate =new DateTime($list['date'])

How can I convert this short PHP function into Javascript? [closed]

六眼飞鱼酱① 提交于 2019-12-13 11:24:29
问题 This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 6 years ago . How can I replicate this PHP code into Javascript ?? It takes a number like 2-9999 (serial number) and converts it into a NUMBER ... 2-999 would be a

Getting field value from object array by key inside object

蓝咒 提交于 2019-12-13 07:26:54
问题 This is very stupid question and I can't believe that im asking about something simple like this. Im using db->get['table']->result() to get data from table. Table schema looks like this: table(id, col1, col2). db->get['table']->result() returns something like this (print_r): Array ( [0] => stdClass Object ( [id] => 1 [col1] => "id 1 col 1" [col2] => "id 1 col 2" ) [1] => stdClass Object ( [id] => 2 [col1] => "id 2 col 1" [col2] => "id 2 col 2" ) [2] => stdClass Object ( [id] => 3 [col1] =>

If condition for PHP Version ignore new code

人盡茶涼 提交于 2019-12-12 09:46:17
问题 So I've got a script that needs to run on several sites. I've got one version of the script that is optimised with some new PHP 5.3 functions, however some sites are 5.2 etc. This code: if (version_compare(PHP_VERSION, '5.3.0') >= 0) { Do the optimised 5.3 code (Although 5.2 throws syntax errors for it) } else { do the slower version of code } However, on the 5.2 servers, it will detect the "syntax errors" in the first if condition, even though it technically should skip that content, I'm

best way append named array to array in PHP 5.2

杀马特。学长 韩版系。学妹 提交于 2019-12-11 11:55:08
问题 I got used to this notation for creating empty arrays and add named elements to them when needed; $array = []; // in case there is an error $array["error"][] = "new error message as element 0 of $array['error']"; Now I learned that the [] notation for arrays does not work in older versions of PHP, like PHP 5.2. Instead I have to do; $array = array( "error" => array() ); array_push($array["error"], "new error message as element 0 of $array['error']"); This way is a little bit inconvenient in

how to pass variables “$tid, $id” into raw function?

ⅰ亾dé卋堺 提交于 2019-12-11 08:20:26
问题 when i call $id and $tid in raw function to fetch some data from sub document of mongodb collection it show me an error these two variables are undefined($tid,$id) ? <?php $id=IntValue; $tId=IntValue; if($tId==0) { $maxPlayers=0; } else { $result = DB::collection('PrizeDistributionTemplate')->raw(function($collection) { return $collection->aggregate(array( array( '$match' => array( 'id' => $id,'templates.tId' => $tid) ), array( '$unwind' => '$templates' ), array( '$match' => array( 'id' =>

Making a PHP closure function safe for PHP 5.2

蓝咒 提交于 2019-12-10 19:08:31
问题 The following function works in PHP > 5.3 but errors out in older versions. How can I modify this to make it 5.2 safe? function _iniloader_get_dirs($dir) { $dirs = array_filter(scandir($dir), function ($item) use ($dir) { return (is_dir($dir.'/'.$item) && $item != "." && $item != ".."); }); // Use array_values to reset the array keys: return array_values($dirs); } 5.2 error: Parse error: syntax error, unexpected T_FUNCTION ... on line 2 回答1: You can easily do it w/o the closure, but you will

Can you hint return types in PHP 5.2.5?

狂风中的少年 提交于 2019-12-10 13:15:13
问题 I think my eclipse's ctrl+clicking links might benefit greatly... Edit: I'm using eclipse PDT. Edit 2: I'm very happy with the solution of putting docblocks before functions (and variables) with an @return or @var statement, I've just updated the documentation of my app and now eclipse is showing me what functions are available to what objects! Awesome. 回答1: // [...] /** * Return the Request object * * @return Zend_Controller_Request_Abstract */ public function getRequest() { return $this->