What am I doing wrong here [message #516920] |
Thu, 25 February 2010 14:05  |
Eclipse User |
|
|
|
Originally posted by: eclipse.iancoetzee.za.net
Hi all
It might just be something stupid that I am overlooking (or ignoring)
I have (for testing purposes) two php files, newfile.php and test.php
in newfile.php I have
> <?php
> class testing
> {
> function test()
> {
> return "1234";
> }
> }
> ?>
and in test.php I have
> <?php
> require_once 'newfile.php';
>
> $test = testing::
> ?>
on line 4 in test.php whenever I start typing "testing" I get a code
assist dialog which pops up and suggest the class "testing" as defined
in newfile.php. However when I press <enter> I expect it to pop up with
a code assist dialog which suggests function "test()". But it does not.
I have tried replacing "function test()" with "public function test()"
but that do not do the trick :(
This is a new PHP 5.3 project I created for the purpose of posting to
this newsgroup.
Thank you in advance
Ian
|
|
|
Re: What am I doing wrong here [message #517131 is a reply to message #516920] |
Fri, 26 February 2010 11:05   |
Eclipse User |
|
|
|
Originally posted by: christian.wolf.sedo.de
Hi Ian,
since you are calling the function test() statically, you should also
declare it static:
newfile.php:
<?php
class testing
{
public static function test()
{
return "1234";
}
}
?>
If you didn't want to call it statically, you should use something like:
test.php:
<?php
require_once 'newfile.php';
$obj = new testing();
$test = $obj->test();
?>
In this case, code completion also works after typing "$obj->".
Best regards,
Christian A. Wolf
|
|
|
Re: What am I doing wrong here [message #517158 is a reply to message #517131] |
Fri, 26 February 2010 12:20  |
Eclipse User |
|
|
|
Originally posted by: eclipse.iancoetzee.za.net
On 2010/02/26 01:05 PM, Christian Alexander Wolf wrote:
> Hi Ian,
>
> since you are calling the function test() statically, you should also
> declare it static:
>
> newfile.php:
> <?php
> class testing
> {
> public static function test()
> {
> return "1234";
> }
> }
> ?>
Adding that "static" worked like a charm, thank you very much
Regards
Ian
|
|
|
Powered by
FUDForum. Page generated in 0.01921 seconds