tags:

views:

518

answers:

7

I am writing a php app on the websever I set up at my house. It is a fedora10 machine, running php5 and mysql. I have code like this:

<?php echo $var->function(); ?>

But for some reason the -> is closing the php tag, so the output has 'function(); ?' added to it...is there something I need to change in my php or webserver configuration?

+4  A: 

I dont think that you have mod_php enabled in your apache config file, or else you would never see the php code in the output. Here is a good tutorial on setting up php 5 in apache.

Shane C. Mason
i think, shane is right. the php code is interpreted as html. in your source you should see the php-code 1 by 1 - nothing is interpreted. the `function()` is displayed because `<?php and ->` act as html-open and -close tags.
Schnalle
A: 

Try

<?php echo("foo"); ?>

If that doesn't work, you don't have PHP enabled in Apache.

Don Werve
yes, php is enabled, I have been using it for a while, just never with any 'OO' php stuff before
W_P
A: 

If your're sure that php is enabled, try this one

<?php
$result = $var -> function();
echo $result;
?>

to debug it a little.. maybe something interesting will raise

DaNieL
A: 

Is the php enabled on server? A simple test for determining it:

<?php phpinfo();?>

Put the above line in a .php file and access it.

Niran
A: 

You could also try this:

<?php phpinfo();

Final closing php tag isn't required.

Vili
A: 

I ran into a similar problem the other day but I was using bar ?> instead of bar; ?>

It turned out that the short_open_tag option was disabled in my PHP configuration.

Sean McSomething
A: 

I had the same problem with a standard XAMPP installation. short_open_tag=On solved it.

Christian