errorhandler_class
Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| errorhandler_class [2019/12/21 22:18] – created sahl | errorhandler_class [2021/02/15 20:56] (current) – sahl | ||
|---|---|---|---|
| Line 4: | Line 4: | ||
| There are also some utility functions for debugging code. | There are also some utility functions for debugging code. | ||
| + | |||
| + | ===== Typechecking ===== | ||
| + | |||
| + | To introduce semi-strict type checking on functions, the class introduces the '' | ||
| + | |||
| + | One pass a variable to the function and then a type name, and if the variable doesn' | ||
| + | |||
| + | Example: | ||
| + | |||
| + | <code php> | ||
| + | /** | ||
| + | * Display name and age of person. | ||
| + | * @param string $name Name of person. | ||
| + | * @param int $age Age of person. | ||
| + | */ | ||
| + | function displayNameAndAge($name, | ||
| + | Errorhandler:: | ||
| + | echo $name.' | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | This will trigger an error if the '' | ||
| + | |||
| + | ==== Types ==== | ||
| + | |||
| + | The following types can be checked. If anything else is typed it is considered a name of a class. | ||
| + | |||
| + | |string| | ||
| + | |int| | ||
| + | |integer| | ||
| + | |float| | ||
| + | |array| | ||
| + | |resource| | ||
| + | |boolean| | ||
| + | |||
| + | integer and floats are checked based on content and not variable type, so a string containing a valid integer number will pass as a integer. | ||
errorhandler_class.1576966696.txt.gz · Last modified: 2019/12/21 22:18 by sahl