Jump to content

include a file in str_replace?


michaellunsford

Recommended Posts

I've been using str_replace to include html files with file_get_contents(). Well, now the challenge is to [color=green]include[/color] a PHP file.

[code]<?php
echo str_replace($string,"|contact_form|",file_get_contents("contact_form.html"));
?>[/code]

if I use file_get_contents(), it just displays the raw PHP script. If I eval() it, I get errors (unexpected '$' on line 1 -- but there is no $ on line 1?)
Link to comment
https://forums.phpfreaks.com/topic/35536-include-a-file-in-str_replace/
Share on other sites

Finally managed to figure it out.

The destination PHP file was including another file that generated a cookie. Seems that eval() doesn't know how to say "headers already sent," so I guess it gave me that weird "unexpected '$' on line 1" error ???

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.