Scalar type declarations come in two flavours: coercive (default) and strict. The following types for parameters can now be enforced (either coercively or strictly): strings (string), integers (int), floating-point numbers (float), and booleans (bool). They augment the other types introduced in PHP 5: class names, interfaces, array and callable.
// Coercive mode
function sumOfInts(int ...$ints)
{
return array_sum($ints);
}
var_dump(sumOfInts(2, '3', 4.1));
The fist lecture of the class, discussions on what makes a dynamic site different to a static site, and then going on to discuss PHP & MySQL definitions with a look and explanation of the 3 tier application system.
01. Introduction To PHP – Download the PDF
01. Introduction To PHP – Download the IPOD VIDEO
Full DetailYou may already know that PHP allows you to define functions with optional arguments. But there is also a method for allowing completely arbitrary number of function arguments.
First, here is an example with just optional arguments: