You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The PHP manual combines all inputs into one section, and the outputs into another, though. I think it'd be easier if the input/output pairs were kept together, like this:
This is related to #23, but I think we should go further and have an entire section, where we can have blocks of code, and prose descriptions. The section could look something like this:
Examples
Individual arguments
prepare() is often called with each un-sanitized value explicitly passed as an individual argument; for example:
$wpdb->prepare( "SELECT id FROM $wpdb->posts WHERE id > %d AND post_status = %s", $min_id, $status )
Array of arguments
The function will also accept an array of un-sanitized values, though, like this:
$wpdb->prepare( "SELECT id FROM $wpdb->posts WHERE id > %d AND post_status = %s", array( $min_id, $status ) )
Dynamic Placeholders
When you have a multi-dimensional array where each sub-array contains a different number of items, you can build the placeholders dynamically:
So if a sub-array has 2 items, then $wordcamp_id_placeholders will be '%d, %d', and if the next array has 4 items, then its placeholder string would be '%d, %d, %d, %d'.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Right now https://developer.wordpress.org/reference/functions/zeroise/ tries to explain the inputs and returns in the description, but it'd be much easier to read and understand in code.
I think it'd be helpful for functions to have a dedicated Examples section, similar to https://www.php.net/manual/en/function.array-splice.php and https://developer.wordpress.org/cli/commands/cli/
The PHP manual combines all inputs into one section, and the outputs into another, though. I think it'd be easier if the input/output pairs were kept together, like this:
This is related to #23, but I think we should go further and have an entire section, where we can have blocks of code, and prose descriptions. The section could look something like this:
Examples
Individual arguments
prepare()
is often called with each un-sanitized value explicitly passed as an individual argument; for example:$wpdb->prepare( "SELECT id FROM $wpdb->posts WHERE id > %d AND
post_status
= %s", $min_id, $status )Array of arguments
The function will also accept an array of un-sanitized values, though, like this:
$wpdb->prepare( "SELECT id FROM $wpdb->posts WHERE id > %d AND
post_status
= %s", array( $min_id, $status ) )Dynamic Placeholders
When you have a multi-dimensional array where each sub-array contains a different number of items, you can build the placeholders dynamically:
So if a sub-array has 2 items, then
$wordcamp_id_placeholders
will be'%d, %d'
, and if the next array has 4 items, then its placeholder string would be'%d, %d, %d, %d'
.Beta Was this translation helpful? Give feedback.
All reactions