CodeIgniter Forums

Full Version: How do these arguments work? [, int $status_code= 500 ] ?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Im not too clear how exactly these arguments are passed.

show_error('message' [, int $status_code= 500 ] )

Why isnt comma just after 'message'? And why square brackets?


Oh and this one too show_404('page' [, 'log_error']) ---- first example it is an int $status_code and here its just 'log_error' -what is the difference?

PS. I do apologize for my stupid questions.
[] are just a replacement for array()

The comma is need because you are passing an array.

The show_404 will display the 404 error message to the browser (not found). The second parameter log_error is a value of TRUE or FALSE.
TRUE will log the error message if logging is enabled.
Thank you, that's what I thought. Is this regular PHP or CI? If its PHP I will try to find more online to read about it.
[] here has nothing to do with arrays ... square brackets are a de-facto standard notation for marking optional parameters in documentation.
Im going to trust Narf since he has three stars lol, but seriously I will have to look into that deeper since Im confused now. Thank you all
Narf is correct. In docs, [] as a parameter denote an optional parameter (also why the comma is inside the [] because if you use the optional parameter, you need the comma to separate parameters).

This is how the official PHP docs (and most others) are written. Example: http://php.net/manual/en/function.html-e...decode.php