PHP problems with new Dreamhost account

software development


Hi people, am trying to move my existing site over here. I say “trying”, because it remains to be seen if I’ll work out all the problems that are preventing me from getting my fully functional complicated site working here the same way that it already does on the old host. :wink:

Anwyay, the old host had php 4.1.2. Now, I have php 4.4.4.

This is kind of complicated, I’ve already posted messages to the various php lists, but I thought it wouldn’t hurt to do it here as well, in case anyone’s seen anything like it.

I’m having a problem now that I’ve gone from php 4.1.2 to php 4.4.4, where preg_replace_callback() is segfaulting when I pass it html that is longer than 2732 bytes. This code has worked for a long time on the other server.

Basically, I am reading an html page template into a variable with fread(). I then populate some variables, modify the text, and end up with a mixed php and text document in the variable.

I then am doing the following, which is code taken from a user example on the eval() php manual page, which I have used successfully for quite awhile:

What it does is evaluate mixed html and php code, and output to browser. You call it like:


function eval_mixed_helper($arr){
return (“echo stripslashes(”".addslashes($arr[1])."");");

function eval_mixed($string){

$string = “<? ?>”.$string."<? ?>";
$string = preg_replace("/<?=\s+(.?)\s+?>/", “<? echo $1; ?>”, $string);
$string = str_replace(’?>’, ‘’, str_replace( array(’<?php', '<?'), '', preg_replace_callback( "/\?>((.|\n)
?)<?(php)?/", “eval_mixed_helper”, $string) ) );

return eval($string);

If the template that I read into $string is 2732 or less bytes, it works like it always did. If it is 2733 or greater bytes, it segment faults, internal server error, preliminary end of script headers etc.

I found this report in the php bug database, but it’s really old. It sounds like the same thing, though:
Bug #25754 preg_replace() and preg_replace_callback() crash with long matches

Anybody know anything about this?

Again, it worked fine on the older php on a different server.
I don’t really know what to do to proceed with this, it’s a bit out of my

Any advice would be greatly appreciated!