Welcome Guest, Not a member yet? Register   Sign In
How do these arguments work? [, int $status_code= 500 ] ?
#1

(This post was last modified: 03-10-2015, 09:36 AM by lexxtoronto.)

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.
Reply
#2

[] 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.
Reply
#3

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.
Reply
#4

[] here has nothing to do with arrays ... square brackets are a de-facto standard notation for marking optional parameters in documentation.
Reply
#5

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
Reply
#6

(This post was last modified: 03-18-2015, 02:22 PM by CroNiX.)

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
Reply




Theme © iAndrew 2016 - Forum software by © MyBB