Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 09-19-2009, 09:37 PM   PM User | #1
nikos101
Senior Coder

 
nikos101's Avatar
 
Join Date: Dec 2006
Location: London
Posts: 1,004
Thanks: 58
Thanked 10 Times in 10 Posts
nikos101 is an unknown quantity at this point
Netscape How do I call a function within a amfphp class

Hi,I need to call a function within a function in a amfphp class I want to call the generateRandStr method in the listMusic() but can't figure out how to do it.

PHP Code:
<?php 

class Audio{


    function 
listMusic(){
    
       
$activationKey Audio->generateRandStr(50);
        
        
    }
    




    
/**
     * generateRandStr - Generates a string made up of randomized
     * letters (lower and upper case) and digits, the length
     * is a specified parameter.
     */
    
private static function generateRandStr($length) {
        
$randstr "";
        for(
$i 0$i $length$i ++) {
            
$randnum mt_rand 061 );
            if (
$randnum 10) {
                
$randstr .= chr $randnum 48 );
            } else if (
$randnum 36) {
                
$randstr .= chr $randnum 55 );
            } else {
                
$randstr .= chr $randnum 61 );
            }
        }
        return 
$randstr;
    }
    
    
 

}

?>
__________________

nikos101 is offline   Reply With Quote
Old 09-19-2009, 09:40 PM   PM User | #2
kbluhm
Senior Coder

 
kbluhm's Avatar
 
Join Date: Apr 2007
Location: Philadelphia, PA, USA
Posts: 1,503
Thanks: 2
Thanked 258 Times in 254 Posts
kbluhm will become famous soon enough
PHP Code:
$activationKey self::generateRandStr(50); 
Static methods are called using the class name, then two colons, then the method name.

If you'e calling the method from within the parent class, you can reference it as `self`, as in the example above.
__________________
ZCE
kbluhm is offline   Reply With Quote
Old 09-19-2009, 09:45 PM   PM User | #3
nikos101
Senior Coder

 
nikos101's Avatar
 
Join Date: Dec 2006
Location: London
Posts: 1,004
Thanks: 58
Thanked 10 Times in 10 Posts
nikos101 is an unknown quantity at this point
I guess static methods are the only ones I can use in the remote object case
__________________

nikos101 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:08 AM.


Advertisement
Log in to turn off these ads.