...

View Full Version : How do I call a function within a amfphp class



nikos101
09-19-2009, 10:37 PM
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

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 ( 0, 61 );
if ($randnum < 10) {
$randstr .= chr ( $randnum + 48 );
} else if ($randnum < 36) {
$randstr .= chr ( $randnum + 55 );
} else {
$randstr .= chr ( $randnum + 61 );
}
}
return $randstr;
}




}

?>

kbluhm
09-19-2009, 10:40 PM
$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.

nikos101
09-19-2009, 10:45 PM
I guess static methods are the only ones I can use in the remote object case



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum