freak1321 Posted August 14, 2007 Share Posted August 14, 2007 My hosting company offers both php 5 and 4. I use php 5. I want to know how to access a php 4 program (or class). It's ffmpeg-php and I want to access this code in php 4 $ffmpegObj = new ffmpeg_movie($filetmp); $duration = $ffmpegObj->getDuration(); ffmpeg-php is only available on php 4 so basically I need to call this function from within php 5. I was guessing something like: $test = exec("/usr/bin/php -r '$ffmpegObj = new ffmpeg_movie($filetmp);$duration = $ffmpegObj->getDuration();'"); echo $test; but that doesn't work - any ideas anyone? Seems like a tough question... :'( Quote Link to comment https://forums.phpfreaks.com/topic/64789-calling-php-4-from-within-php-5/ Share on other sites More sharing options...
btherl Posted August 14, 2007 Share Posted August 14, 2007 You have a problem there in that the code in double quotes will have variable substitution done BEFORE being passed to php4. Try enclosing it in single quotes instead. You will need to escape single quotes within the string also. Eg. $test = exec('/usr/bin/php -r \'$ffmpegObj = new ffmpeg_movie($filetmp);$duration = $ffmpegObj->getDuration();\''); Quote Link to comment https://forums.phpfreaks.com/topic/64789-calling-php-4-from-within-php-5/#findComment-323246 Share on other sites More sharing options...
freak1321 Posted August 15, 2007 Author Share Posted August 15, 2007 Your right about the problem with the quotation marks (or maybe its something else)... I can't even get any of these to work - could anyone come up with a simple working example? $test = system('/usr/bin/php -r \'echo "hi";\''); echo $test; OR $st = 'hello'; $test = system('/usr/bin/php -r \'echo $st;\''); echo $test; OR $st = 'hello'; $test = system('/usr/bin/php -r \'echo '.$st.'\''); echo $test; Quote Link to comment https://forums.phpfreaks.com/topic/64789-calling-php-4-from-within-php-5/#findComment-324490 Share on other sites More sharing options...
btherl Posted August 16, 2007 Share Posted August 16, 2007 Here you go: $st = 'hello'; $command = '/usr/bin/php -r \'echo "'.$st.'";\''; print "About to execute $command\n"; $test = system($command); echo $test; Much better to print out the command before executing, so you can visually inspect it. Dealing with shell escaping is a hassle though, for any more complicated code. Quote Link to comment https://forums.phpfreaks.com/topic/64789-calling-php-4-from-within-php-5/#findComment-325279 Share on other sites More sharing options...
freak1321 Posted August 16, 2007 Author Share Posted August 16, 2007 Your totally right - and that totally worked - thanks so much! Funny how things always seem so simple in hindsight! Quote Link to comment https://forums.phpfreaks.com/topic/64789-calling-php-4-from-within-php-5/#findComment-325352 Share on other sites More sharing options...
keeB Posted August 16, 2007 Share Posted August 16, 2007 How about porting that library to PHP5 ? Shouldn't be too difficult Quote Link to comment https://forums.phpfreaks.com/topic/64789-calling-php-4-from-within-php-5/#findComment-325379 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.