Re: classes
| From: | Shawn McKenzie | Date: | Mon, 18 Feb 2008 22:13:48 +0000 |
| Subject: | Re: classes | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-269569@lists.php.net to get a copy of this message | ||
Nick Stinemates wrote:
> Shawn McKenzie wrote:
>> Jay Blanchard wrote:
>>
>>> [snip]
>>> if i declare an instance of a class in the top of my php file, then
>>> have html, then later on user $myClassInstance->myMethod(); --
>>> myMethod() does not execute, only when i have the instantiation of the
>>> class right before the call to the method does it work. any ideas?
>>> [/snip]
>>>
>>> You are no longer running the script once the output has been sent to
>>> the screen. You need to flush output to the screen or re-order your
>>> code.
>>>
>>> http://www.php.net/flush
>>>
>> Huh, what?!?! to both of you:
>>
>> <?php
>> $myClassInstance = new myClass();
>> ?>
>> Hello
>> <?php
>>
>> $myClassInstance->myMethod();
>>
>> class myClass
>> {
>> function myMethod()
>> {
>> echo " world!";
>> }
>> }
>> ?>
>>
>> Outputs the expected. Must be an error, maybe fatal or parse before the
>> method call or maybe your method does execute you just are expecting
>> something different?
>>
>> -Shawn
>>
>>
> What part of my example was unclear?
>
All of it, since I posted just a couple minutes after you and I hadn't
seen your post yet.