Petes
05-01-2006, 11:18 PM
I'm getting some odd results when using <?php or ?> in a script.
What I am doing is parsing a PHP/HTML file, and passing the segments to a form via a hidden input. I don't want to execute the code, just pass it on for inclusion in a file.
My question is this: Can I use the PHP open and or close tags in function arguements, or variables, without breaking the code? My guess was no, but the parsing "seems" to work, but when it goes to the form I get odd stuff. So I'm wondering if I'm just plain trying to do a no-no here.
Example (breaks file into PHP and HTML pieces, then passes pieces to a form for editing, recombining and saving):
preg_match_all("|(<\?php.*\?>)(.*)(<\?php.*\?>)|s", $contents, $matches);
$head = nl2br(htmlentities($matches[1][0]));
//thus $head is something like <?php some stuff ?>
...
<input type="hidden" name="head" value="$head" />
So is using raw PHP open/close tags in an argument, or passing passing them in a variable not possible/good practice?
Thanks.
What I am doing is parsing a PHP/HTML file, and passing the segments to a form via a hidden input. I don't want to execute the code, just pass it on for inclusion in a file.
My question is this: Can I use the PHP open and or close tags in function arguements, or variables, without breaking the code? My guess was no, but the parsing "seems" to work, but when it goes to the form I get odd stuff. So I'm wondering if I'm just plain trying to do a no-no here.
Example (breaks file into PHP and HTML pieces, then passes pieces to a form for editing, recombining and saving):
preg_match_all("|(<\?php.*\?>)(.*)(<\?php.*\?>)|s", $contents, $matches);
$head = nl2br(htmlentities($matches[1][0]));
//thus $head is something like <?php some stuff ?>
...
<input type="hidden" name="head" value="$head" />
So is using raw PHP open/close tags in an argument, or passing passing them in a variable not possible/good practice?
Thanks.