0

i was having a look at a php script (namesilo module for whmcs) and found this function

function namesilo_transactionCall($callType, $call, $params)

and later in the script, it is called with the following code

namesilo_transactionCall("getNameServers", $apiServerUrl . "/api/getDomainInfo?version=1&type=xml&key=$apiKey&domain=$sld.$tld");

When it is called there is only two parameters and when the function was declared, the $params was not made optional. How is it possible. I am relatively new to php

1
  • I think it's not possible! something is wrong Commented Jan 26, 2014 at 19:25

1 Answer 1

1

I saw @Alireza Fallah comment, and decided to answer . Why it`s impossible?

 <?php 

  function namesilo_transactionCall($callType, $call, $params){
    var_dump($callType);
  }

  namesilo_transactionCall(1,1);
  // OUTPUT
  1

 ?>

If you doesnt pass defined not-optional agrument - interpreter generate Warning like:

Warning: Missing argument 3 for namesilo_transactionCall()

Set error_reporting(0) - and you never see this. You can ,in general, not specify all parameters like as here:

 function A(){  
   print_r(func_get_args());
 }

 // and call 

 A(1,2,3,4,5,6,7,8....N);

And this code will work. See more about functions in PHP.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.