Page 1 of 1

Calling Method Closes PHP. interpreted as '?>'

Posted: Tue Aug 12, 2008 3:51 pm
by securinx
Hi all,

I'm new here but have been coding for a while.. I've never run across this though, was hoping maybe somebody here had and could give me a tip. I am basically on a clients new box. php 5.2.4/apache 2.2. I am implementing classes and I can instantiate them fine, but when I go to call a method, Somehwere the '->' is interpreted as a ?> close tag so :

Code: Select all

 
$class = new class; // works fine
 
$class->retrieve(); // returns "retrieve();" (equivalent of $class?>retrieve();
 
I have checked httpd.conf and php.ini but cant find where this happens. asp tags are off. has anybody ran into this?

Beto

Re: Calling Method Closes PHP. interpreted as '?>'

Posted: Tue Aug 12, 2008 6:37 pm
by ghurtado
Your theory sounds fishy to me. If that were the case, you would get a PHP parsing error due to the missing semicolon. I think it is a lot more likely that PHP parsing is not enabled in apache, and your browser shows you the rest of what it considers to be "outside" the php "Tag", after it encounters ">". Take a look at the source of the page and post it here.

Re: Calling Method Closes PHP. interpreted as '?>'

Posted: Wed Aug 13, 2008 1:31 am
by jmut
I guess you put some valid identifier for class name but 'class' is reserved word and new class is parse error.
@ghurtado Last statment wouldn't require semicolon;

Code: Select all

 
//this is ok;
<?php
$var = 1;
echo $var
?>
 

Re: Calling Method Closes PHP. interpreted as '?>'

Posted: Wed Aug 13, 2008 9:27 am
by ghurtado
Thanks jmut, I never knew that.

I still believe PHP is not getting parsed, since all that is output is "retrieve();"

Re: Calling Method Closes PHP. interpreted as '?>'

Posted: Wed Aug 13, 2008 2:38 pm
by securinx
Thanks for the tips guys. hurtado you;re right, it wasn;t getting parsed. the box wasn't set up to recognize <?, only <?php .

Beto