Search code examples
phpruby-on-railsfunction-parameter

How do I specify some parameter while keeping the parameters before it default in php


In functions such as the wordpress function wp_title. I have noticed they can have multiple parameters such as $sep, $display, $seplocation (using wp_title as a example).

I know with Ruby on Rails you can change any parameter such as $seplocation by using :seplocation => "left" or :seplocation => "right" while still keeping the other parameters as their defualt value. Therefore to bring me to my question: How do you make parameters such as $seplocation a specified parameter while keeping the others their default parameters?

Btw sorry if this is a duplicate, I did search to make sure it was not a duplicate however I am pressed for time and could not search as long as I would like.

Thanks for the help.

P.S. The ruby-on-rails tag was put in because I used ruby on rails as an example for my question.


Solution

  • I don't know WordPress, but to pass arguments to a function and skip some, just pass null for the ones to skip:

    $result = wp_title($sep, null, $seplocation);