Search the web
Sign In
New User? Sign Up
id-php · Diskusi Milis PHP Indonesia
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Hear how Yahoo! Groups has changed the lives of others. Take me there.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
SOLVED Re: [id-php] Fungsi Dinamis   Message List  
Reply | Forward Message #30848 of 32487 |
Thanks atas idenya, memang itu yang saya cari,
dengan sedikit perbaikan, scriptnya jalan dengan:

eval("?>"."<?php echo $function($op);?>")

Thanks again,


2009/7/5 Youppie Arliansyah <youppie@...>:
>
>
> Kalau begini gimana?
>
> if(function_exists($function)){
> eval("echo $function($op);");
>
> }else{
> echo 'fungsi tidak ditemukan';
> }
>
> 2009/7/5 Hermann Golden <netscripts@...>:
>>
>>
>> Maaf nggak bisa cara gitu juga, soalnya fungsi(variable) ,
>> variable-nya itu berubah-ubah juga,
>> FYI $op itu diambil dari querystring , jadi misalkan :
>>
>> http://localhost/?mod=tampil/ini/2
>> http://localhost/?mod=tampil/delete/2/confirm
>>
>> $arg[0] hasilnya tampil
>> $arg[1] hasilnya ini atau delete
>> dst.
>> jadi bila ada fungsi tampil($arg[0],$arg[1]){ maka jalankan kalo tidak
>> maka harus menghasilkan warning, misalkan
>> missing argument 1
>>
>> jadi argumen fungsinya belum diketahui, tergantung querystring,
>> namanya juga dinamis, mirip-mirip framework lah, geto.
>>
>> Thanks
>>
>> 2009/7/5 Youppie Arliansyah <youppie@...>:
>>
>>>
>>>
>>> echo $function($op[0],$op[1],$op[2],$op[3]);
>>>
>>> 2009/7/5 Hermann Golden <netscripts@...>:
>>>
>>>>
>>>>
>>>> Maaf fungsi test() tidak boleh diutak-atik Om, mesti begitu, soalnya
>>>> tidak semua fungsi yang nantinya saya buat pake implode , namanya juga
>>>> dinamis
>>>>
>>>> Thanks
>>>>
>>>> 2009/7/5 StandAloneâ„¢ <lhutfhy@...>:
>>>>
>>>>>
>>>>>
>>>>> hmmmmm,
>>>>> seharusnya seh function nya dah error, karena cuma nerima 1 parameter.
>>>>> lagi pula, alasan menjadi tiga, empat, lima, enam dan dan dan
>>>>> adalah karena $ops di-implode pake ','
>>>>>
>>>>> coba di-implode pake ' dan ';
>>>>> dan biarin di implode di function.
>>>>>
>>>>> jadi:
>>>>>
>>>>> function test($a)
>>>>> {
>>>>> echo implode(' dan ', $a);
>>>>> }
>>>>>
>>>>> ๑۩۩๑oº*ºo.. -------------------------- ..oº*ºo๑۩۩๑
>>>>> Maka nikmat Tuhan kamu yang manakah yang kamu dustakan?
>>>>> ~~~~~~~~~~~~~~~~~~~~~~
>>>>> http://standalone.blogsome.com
>>>>> http://pribadi.wordpress.com
>>>>> http://www.lhutfhy.co.cc
>>>>> ~~~~~~~~~~~~~~~~~~~~~~
>>>>>
>>>>> On Sun, Jul 5, 2009 at 8:33 AM, Hermann Golden <netscripts@...>
>>>>> wrote:
>>>>>
>>>>>> <?php
>>>>>> $arg[] = 'satu';
>>>>>> $arg[] = 'dua';
>>>>>> $arg[] = 'tiga';
>>>>>> $arg[] = 'empat';
>>>>>> $arg[] = 'lima';
>>>>>> $arg[] = 'enam';
>>>>>>
>>>>>> for($i=2;$i<=count($arg)-1;$i++){
>>>>>> $ops[] = $arg[$i];
>>>>>> }
>>>>>> $op = implode(',',$ops);
>>>>>> $function = 'test';
>>>>>> if(function_exists($function)){
>>>>>> echo $function($op);
>>>>>> }else{
>>>>>> echo 'fungsi tidak ditemukan';
>>>>>> }
>>>>>>
>>>>>> function test($a,$b,$c,$d){
>>>>>> echo $a.' and '.$b.' and '.$c.' and '.$d;
>>>>>> }
>>>>>> ?>
>>>>>>
>>>>>> Kenapa hasil yang keluarnya adalah "tiga,empat,lima,enam and and and
>>>>>> " , hasil yang diharapkan seharusnya "tiga and empat and lima and enam
>>>>>> "
>>>>>>
>>>>>> Terimakasih.
>>>>>>
>>>>>>
>>>>>> ------------------------------------
>>>>>>
>>>>>> Yahoo! Groups Links
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>> [Non-text portions of this message have been removed]
>>>>>
>>>>>
>>>>
>>>> --
>>>> Hosting that never sleeps
>>>> http://www.hosting24.com/page/589?features
>>>>
>>>>
>>>
>>> --
>>> Youppie
>>>
>>
>> --
>> Hosting that never sleeps
>> http://www.hosting24.com/page/589?features
>>
>>
>
> --
> Youppie
>



--
Hosting that never sleeps
http://www.hosting24.com/page/589?features



Sun Jul 5, 2009 12:03 pm

hermann_golden
Offline Offline
Send Email Send Email

Forward
Message #30848 of 32487 |
Expand Messages Author Sort by Date

Thanks atas idenya, memang itu yang saya cari, dengan sedikit perbaikan, scriptnya jalan dengan: eval("?>"."<?php echo $function($op);?>") Thanks again, ... --...
Hermann Golden
hermann_golden
Offline Send Email
Jul 5, 2009
12:03 pm

kok sepertinya sama dengan penggunaan call_user_func($function, $op)[1][2] ya? [1]http://nz.php.net/manual/en/function.call-user-func.php [2]Sorry kalau sudah...
Arief Bayu Purwanto
ar1ef_310
Offline Send Email
Jul 8, 2009
7:57 am
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help