title: Optional parameters in PHP function without considering order
body: <p>Is there a way in PHP to use a function which has optional parameters in its declaration where I do not have to pass an optional arguments which already have values declared and just pass the next argument(s) which have different values that are further down the parameter list. </p>
  
  <p>Assuming I have a function that has 4 arguments, 2 mandatory, 2 optional. I don't want to use null values for the optional arguments. In usage, there are cases where I  want to use the function and the value of the 3<sup>rd</sup> argument is the same as the default value but the value of the 4<sup>th</sup> argument is different. </p>
  
  <p>I am looking for a not so verbose solution that allows me to just pass the argument that differs from the default value without considering the order in the function declaration.</p>
  
  <pre><code>  createUrl($host, $path, $protocol='http', $port = 80) {
      //doSomething
      return $protocol.'://'.$host.':'.$port.'/'.$path;
    }
  </code></pre>
  
  <p>I find myself repeating declaring variables so that I could use a function i.e to use $port, I redeclare $protocol with the default value outside the function scope i.e</p>
  
  <pre><code>$protocol = "http";
  $port = 8080;
  </code></pre>
  
  <p>Is there any way to pass the 2nd optional parameter($port) without passing $protocol and it would "automatically" fill in the default value of $protocol i.e</p>
  
  <pre><code> getHttpUrl($server, $path, $port);
  </code></pre>
  
  <p>This is possible in some languages like Dart in the form of Named Optional parameters.See usage in this <a href="https://stackoverflow.com/questions/13264230/what-is-the-difference-between-named-and-optional-parameters-in-dart">SO</a> thread. Is their a similar solution in PHP</p>