PHP3 to PHP converter

Hey! It aint that hard!
Post Reply
SloppyGoat
BIG GIANT HEAD I Get Free Beer
BIG GIANT HEAD I Get Free Beer
Posts: 1778
Joined: 12/30/02, 12:00 am
Contact:

Post by SloppyGoat » 03/27/03, 5:17 am

Ok, this appears to be some code to convert PHP3 to PHP on a *nix server. Not knowing much about *nix, is it possible to make this work on a IIS server? I'd assume I just have to change the path in the top line? That would be the path to his PHP folder on the *nix server, right? If so, what does that "#!" mean, and what would I change? Everything after that? Or would I replace that with C:? This seems like it's probably some beautiful code. I'd love to see it work. Anyone got a clue?

<!-- BBCode Start --><TABLE BORDER=0 ALIGN=CENTER WIDTH=85%><TR><TD><font class=postbody>Code:</font><HR width=100% color=#333333 SIZE=1></TD></TR><TR><TD><FONT class=code><PRE>
#!/usr/bin/php -q
<?php
// Convert .php3 to .php
// ( and internal refs )
//
function doFile($var) {
if (substr($var,strlen($var)-4,4) == "php3") {
$orig = $var;
$new = substr($orig,0,strlen($orig)-1);
$cmd = "sed 's/php3/php/g' $orig > $new;rm -f $orig";
$res = exec($cmd,$res);
echo "Orig: $origtNew: $newn";
} else {
echo "--Skipping: $varn";
}
}
$dir=(is_array($argv) && $argv[1]) ? $argv[1] : ".";
$a = `find $dir -depth -type f -print`;
$files = explode ("n", $a);
echo "Files: ".count($files)."n";
foreach($files as $item) {
doFile($item);
}
echo "Done.n";
?>
</PRE></FONT></TD></TR><TR><TD><HR width=100% color=#333333 SIZE=1></TD></TR></TABLE><!-- BBCode End -->
Does anybody really know what time it is?
The Grey Area - Tweaking Obsession

RedRage
BIG GIANT HEAD I Get Free Beer
BIG GIANT HEAD I Get Free Beer
Posts: 1542
Joined: 12/04/01, 12:00 am

Post by RedRage » 03/27/03, 12:36 pm

PHP3 to PHP?

I've never noticed PHP3 having difficulty running on a PHP4 system (*nix).

Pogrelz
BIG GIANT HEAD I Get Free Beer
BIG GIANT HEAD I Get Free Beer
Posts: 1093
Joined: 03/03/02, 12:00 am
Contact:

Post by Pogrelz » 03/27/03, 1:54 pm

Same here... Works fine :?

That top line looks...... perlish?

<font class=editedby>[ This Message was edited by: Pogrelz on 2003-03-27 21:55 ]</font>

RedRage
BIG GIANT HEAD I Get Free Beer
BIG GIANT HEAD I Get Free Beer
Posts: 1542
Joined: 12/04/01, 12:00 am

Post by RedRage » 03/27/03, 10:27 pm

the !#/usr/bin/php -q allows it to run like a shell script :-) ( dosn't send the content type)

Pogrelz
BIG GIANT HEAD I Get Free Beer
BIG GIANT HEAD I Get Free Beer
Posts: 1093
Joined: 03/03/02, 12:00 am
Contact:

Post by Pogrelz » 03/28/03, 2:39 am

ah, thanks for the info.

SloppyGoat
BIG GIANT HEAD I Get Free Beer
BIG GIANT HEAD I Get Free Beer
Posts: 1778
Joined: 12/30/02, 12:00 am
Contact:

Post by SloppyGoat » 03/28/03, 8:33 am

Most people have no desire to run php3 with php4. I know I don't. I never mix php3 and php extensions. Some php3 won't even run, for some reason. I did try it. Maybe this isn't so on *nix servers?

<font class=editedby>[ This Message was edited by: SloppyGoat on 2003-03-28 16:35 ]</font>

RedRage
BIG GIANT HEAD I Get Free Beer
BIG GIANT HEAD I Get Free Beer
Posts: 1542
Joined: 12/04/01, 12:00 am

Post by RedRage » 03/28/03, 12:05 pm

in my mime types for apache i tell apache to run php3 as php4. maybe they removed some of the older functions but generally PHP4 has pretty good compatability.

Post Reply