Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Senior Coder nikos101's Avatar
    Join Date
    Dec 2006
    Location
    London
    Posts
    1,008
    Thanks
    59
    Thanked 10 Times in 10 Posts

    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;
        }
        
        
     

    }

    ?>


  • #2
    Senior Coder kbluhm's Avatar
    Join Date
    Apr 2007
    Location
    Philadelphia, PA, USA
    Posts
    1,509
    Thanks
    3
    Thanked 258 Times in 254 Posts
    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.

  • #3
    Senior Coder nikos101's Avatar
    Join Date
    Dec 2006
    Location
    London
    Posts
    1,008
    Thanks
    59
    Thanked 10 Times in 10 Posts
    I guess static methods are the only ones I can use in the remote object case



  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •