Voting

: two plus three?
(Example: nine)

The Note You're Voting On

sebastian at sebastian-eiweleit dot de
11 years ago
<?php
namespace ExampleWorld;
// The Class
class helloWorld {
/* Method with two required arguments */

public function requiredTwoArguments ( $var1, $var2 ) {
// Some code ...
}

/* Method with two arguments, but just one is required */
public function requiredOneArgument ( $var1, $var2 = false ) {
// Some code ...
}
}

$r = new \ReflectionMethod ( 'ExampleWorld\helloWorld', 'requiredTwoArguments' );
echo
$r->getNumberOfRequiredParameters ();

$r = new \ReflectionMethod ( 'ExampleWorld\helloWorld', 'requiredOneArgument' );
echo
$r->getNumberOfRequiredParameters ();

// Output: 2 1

<< Back to user notes page

To Top