tags:

views:

35

answers:

3

Hello, I have a php-file which includes another html-file:

<? virtual("../top.html");?>

The problem is that any code before this include compiles and runs well, after - nothing. There aren't any errors etc. After commenting this line, everything works.

Code was written under local computer with ArchLinux + LAMP. Now I have ubuntu 10.04 with the same configuration.

What could it be?

A: 

Can you check error log of the Apache?

Also, you should use

<?php virtual("../top.html");?>

if your php.ini has short_open_tag = Off.

+1 for not using short tags.
Jeremy Kendall
Log is empty, short tags are allowed.
Ockonal
+1  A: 

You might try changing top.html to top.phtml and using require_once.

<?php require_once('../top.phtml'); ?>
Jeremy Kendall
yeah, this works. But why?
Ockonal
php will parse a .phtml file as if it were php, so you can use require_once on it. I use phtml for template files mostly, to imply that the files include mostly html with just a little php thrown in.
Jeremy Kendall
Also, `virtual()` is apache specific (http://php.net/virtual), and kind of mimics #include virtual. #include virtual sometimes has problems including .html files, requiring you to name them .shtml. I'd recommend using the .phtml extension over .shtml.
Jeremy Kendall
+1  A: 

If you just want to pass some html from a file into your output, you could also use:

<?php echo file_get_contents('../top.html'); ?>

That way, you stay independent of the underlying webserver and you make sure, that no php code that may be in the html is being executed.

However if you wish something in there to be executed, you can use require_once() as stated by Jeremy.

Techpriester