I would like to emanate a duty that can accept multiple, optional, and
offer values in a parameter.For example, we wish to have a classclass
Pizza { open duty addToppings($additional_toppings) { }}which we
can use in my way as $pizza1=new Pizza;$pizza1->addToppings(SALAMI + HAM +
BACON + ADDITIONAL_CHEESE);$pizza2=new Pizza;$pizza2->addToppings(HAM +
PINEAPPLE + SAUSAGE);where toppings can be of any multiple and a choices
for a topics tumble underneath a predefined set.How do we exercise a
addToppings function? I've seem to remember observant something identical
in PHP though we can't remember which.On a other, would we advise
associate arrays
instead?$pizza1->addToppings(array('salami','ham','bacon','additional_cheese'));$pizza2->addToppings(array('ham','pineapple','sausage'));This
choice seems simpler, though we wish to get your ideas that we will select
and why. ThanksEDIT:I now remember one such PHP implementation.The
error_reporting duty allows naming multiple, offer blunder turn constants
as a parameter such as:error_reporting(E_ERROR | E_WARNING |
E_PARSE);error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);So is a
doing of error_reporting() certified wholly given it is partial of PHP
though can't be recreated otherwise?
No comments:
Post a Comment