Re: func_$var() in PHP4?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 6/22/07, Stut <stuttle@xxxxxxxxx> wrote:
Tijnema wrote:
> Hi all,
>
> How can I get this in PHP4?
> I used this in PHP5:
> <?php
>
> class ABC
> {
> function func_a()
> {
> return "a";
> }
> function func_b()
> {
> return "b";
> }
> }
>
> $abc = new ABC();
> $var = a;
> $result = $abc->func_$var(); // Line 17
> ?>
>
> In PHP5 $result contains "a" here, but in PHP4 I get this error:
> Parse error: syntax error, unexpected T_VARIABLE in /xxxx/test.php on
> line 17.
>
> Does anyone know how to accomplish this with PHP4?

$abc = new ABC();
$var = a; // <-- shouldn't this have quotes??
Yes, forgot it when typing this code in gmail, that's why we need PHP
Color Coding ;)
$f = 'func_'.$a;
$result = $abc->$f(); // Line 17

-Stut

Thanks, this code works :)

Tijnema
--
Vote for PHP Color Coding in Gmail! -> http://gpcc.tijnema.info

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux