php4

Is there a call_user_func() equivalent to create a new class instance?

自古美人都是妖i 提交于 2019-11-27 09:02:01
How can I create a class with a given array of arguments to be sent to the constructor? Something along the lines of: class a { var $args = false; function a() {$this->args = func_get_args();} } $a = call_user_func_array('new a',array(1,2,3)); print_r($a->args); Ideally this needs to work, without modification to the class, in both PHP4 and PHP5. Any ideas? ReflectionClass:newInstance() (or newInstanceArgs()) let's you do that. e.g. class Foo { public function __construct() { $p = func_get_args(); echo 'Foo::__construct(', join(',', $p), ') invoked'; } } $rc = new ReflectionClass('Foo'); $foo

php output with sleep()

我怕爱的太早我们不能终老 提交于 2019-11-26 17:48:48
问题 I'm trying to run a loop every second for 25 seconds basically. for($i = 0; $i <= 25; $i += 1){ echo $i; sleep(1) } The thing is it doesn't output until it's fully done, so after the loop continues 25 times. Is there a way to do this so it will output before each sleep? and not wait until the full loop is complete? Thanks! 回答1: What you're trying to achieve is incremental output to the browser from PHP. Whether this is achievable can depend on your server and how you're invoking PHP. PHP

PHP: Loop through all months in a date range?

◇◆丶佛笑我妖孽 提交于 2019-11-26 15:37:43
问题 If I have a start date (say 2009-02-01 ) and an end date (say 2010-01-01 ), how can I create a loop to go through all the dates (months) in the range? 回答1: Try $start = $month = strtotime('2009-02-01'); $end = strtotime('2011-01-01'); while($month < $end) { echo date('F Y', $month), PHP_EOL; $month = strtotime("+1 month", $month); } Mind the note http://php.net/manual/de/datetime.formats.relative.php Relative month values are calculated based on the length of months that they pass through. An

Official end of support for PHP4?

青春壹個敷衍的年華 提交于 2019-11-26 14:53:22
问题 Is there an official date for when support for PHP4 will end? I keep reading this date and that on various sites and blogs, but can't find anything on the PHP website. Am I overlooking something? 回答1: PHP4 is already way past the support. I think support ended more than a year ago. 回答2: Support was officially discontinued on 2007-12-31! 回答3: PHP4 was no longer developed since 2007-12-31, although some security issues were still taken care of up until 2008-08-08. Just before that, the latest

Is there a call_user_func() equivalent to create a new class instance?

你。 提交于 2019-11-26 14:27:38
问题 How can I create a class with a given array of arguments to be sent to the constructor? Something along the lines of: class a { var $args = false; function a() {$this->args = func_get_args();} } $a = call_user_func_array('new a',array(1,2,3)); print_r($a->args); Ideally this needs to work, without modification to the class, in both PHP4 and PHP5. Any ideas? 回答1: ReflectionClass:newInstance() (or newInstanceArgs()) let's you do that. e.g. class Foo { public function __construct() { $p = func

Generate preview image from Video file?

女生的网名这么多〃 提交于 2019-11-26 07:20:46
问题 Is there a way in PHP given a video file ( .mov , .mp4 ) to generate a thumbnail image preview? 回答1: Take a look at http://ffmpeg.org/ along with this discussion http://board.phpbuilder.com/showthread.php?10327812-How-to-install-ffmpeg-php-to-create-thumbnails-from-videos 回答2: Solution #1 (Older) (not recommended) Firstly install ffmpeg-php project (http://ffmpeg-php.sourceforge.net/) And then you can use of this simple code: <?php $frame = 10; $movie = 'test.mp4'; $thumbnail = 'thumbnail.png