RyanTCB RyanTCB - 1 year ago 92
MySQL Question

Need help understanding PHP documentation semantics

I use a little bit of php to work with a database. Never used it enough to explore what it can do. Until now. I went looking at the documentation and I see a function I have used countless times. I thought I knew how to use it until the docs and now I'm baffled

mixed mysqli_query ( mysqli $link , string $query [, int $resultmode = MYSQLI_STORE_RESULT ] )

In my php that is simply

mysqli_query($connection, $anMySQLQuery);

Where I'm confused is the use of

[, int $resultmode = MYSQLI_STORE_RESULT ]

What's with the [] and the comma after the opening [?

As a reader of the docs what does [, indicate ?

Answer Source

It's not related to php, lots of programming languages / libraries use this convention to tell us the parameter(s) beetween [] are optionnal.

foo(bar[,baz]) means the function foo takes at least 1 argument, bar and an optional baz parameter.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download