Page 1 of 1

PHP Include Not Parsing

Posted: Sun Mar 25, 2007 12:55 pm
by serfczar_
I know my php code is right, and I just recently installed php5 and apache2 on my localhost. i moved some scripts over and the include doesn't seem to want to parse my template.class.php file! and when I click view source it has that file there in text version, what should I do?

Posted: Sun Mar 25, 2007 1:22 pm
by feyd
Did you write the file with short open tags?

Posted: Sun Mar 25, 2007 3:41 pm
by serfczar_
feyd wrote:Did you write the file with short open tags?
no i didn't here is the two files...

Code: Select all

<?php include'include/config.php'; include'include/class/template.class.php'; ?>
the first include seems to be fine i think....


This is the included file, returning to the browser full text of the file.

Code: Select all

<?
class Template {
public $template;
  function load($filepath) {
    $this->template = file_get_contents($filepath);
  }
  function replace($var, $content) {
    $this->template = str_replace("#$var#", $content, $this->template);
  }
  function amend($var, $content) { 
  if($_POST['amend'] != ""){
    $temp0 = $_POST['amend'];
	$temp1 = $_POST['amend'];
	$temp1 .= $content;
	$this->template = str_replace($temp0, $temp1, $this->template);
  }
		else{
		$_POST['amend'] = $content;
		$this->template = str_replace("#$var#", $content, $this->template);
		}
  }
  function loopit($var, $content, $counter, $num) {
	$num--;
	if($_POST['data'] != ""){
	$all = $_POST['data'];
	$all .= "$content";
	$_POST['data'] = $all;
	}
		else{
		$all = $content;
		$_POST['data'] = $all;
		}
	if($counter==$num){
	$this->replace($var, $all);
	return $var;
	return $all;
	}
}
function publish() {
	eval("?>".$this->template."<?");
   }
}
?>

Posted: Mon Mar 26, 2007 8:59 am
by feyd
The included file has short tags. Your server has that feature off (as it should.)

Posted: Mon Mar 26, 2007 4:00 pm
by serfczar_
feyd wrote:The included file has short tags. Your server has that feature off (as it should.)
Ahh thx, I didn't notice i used short tags, that was an accident, thanks for spotting that for me!

So short tags off in an included file is a security feature?

Posted: Mon Mar 26, 2007 4:03 pm
by feyd
It's not a security detail. It's related to the setting being optional in PHP 5 and lower builds and it not existing in PHP 6 at all. Normal tags keeps your code more portable.

Posted: Mon Mar 26, 2007 4:21 pm
by serfczar_
feyd wrote:It's not a security detail. It's related to the setting being optional in PHP 5 and lower builds and it not existing in PHP 6 at all. Normal tags keeps your code more portable.
Cool, php6, i'm going to have to go check on that. I didn't realize they had perfected version 5 yet ?_?

Posted: Mon Mar 26, 2007 7:57 pm
by feyd
They haven't finished working on 5. They haven't finished working on 4 either.

Posted: Tue Mar 27, 2007 5:09 pm
by serfczar_
feyd wrote:They haven't finished working on 5. They haven't finished working on 4 either.
ha, they need to get things together. Although it is my favorite language. I do guess though you can never really be finished with a release, to many possibilities.