PHP Include Not Parsing

Need help installing PHP, configuring a script, or configuring a server? Then come on in and post your questions! We'll try to help the best we can!

Moderator: General Moderators

Post Reply
User avatar
serfczar_
Forum Commoner
Posts: 34
Joined: Sun Feb 25, 2007 5:27 pm
Location: USA, Texas
Contact:

PHP Include Not Parsing

Post 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?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Did you write the file with short open tags?
User avatar
serfczar_
Forum Commoner
Posts: 34
Joined: Sun Feb 25, 2007 5:27 pm
Location: USA, Texas
Contact:

Post 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."<?");
   }
}
?>
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

The included file has short tags. Your server has that feature off (as it should.)
User avatar
serfczar_
Forum Commoner
Posts: 34
Joined: Sun Feb 25, 2007 5:27 pm
Location: USA, Texas
Contact:

Post 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?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
User avatar
serfczar_
Forum Commoner
Posts: 34
Joined: Sun Feb 25, 2007 5:27 pm
Location: USA, Texas
Contact:

Post 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 ?_?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

They haven't finished working on 5. They haven't finished working on 4 either.
User avatar
serfczar_
Forum Commoner
Posts: 34
Joined: Sun Feb 25, 2007 5:27 pm
Location: USA, Texas
Contact:

Post 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.
Post Reply