programmieren:php:wichtigefunktionen
Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| programmieren:php:wichtigefunktionen [2026/07/31 10:19] – created admin | programmieren:php:wichtigefunktionen [2026/08/21 16:04] (current) – memory usage admin | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | wichtigefunktionen | + | ====== Wichtige Funktionen ====== |
| + | |||
| + | ===== Array Functions ===== | ||
| + | |||
| + | Some stuff that I think is important in base PHP is the [[https:// | ||
| + | |||
| + | <code php> | ||
| + | $array = array_merge_recursive(...$array) | ||
| + | </ | ||
| + | |||
| + | My beloved. This is used to get arrays nested within other arrays to all be on the same level. | ||
| + | |||
| + | ===== Debugging functions ===== | ||
| + | |||
| + | <code php> | ||
| + | debug($anyVariableYouMayWantToDebug) | ||
| + | </ | ||
| + | |||
| + | CakePHP only. PHP Equivalent is print_r(). | ||
| + | Is useful to debug certain things and to set a breakpoint right at that place. | ||
| + | |||
| + | <code php> | ||
| + | var_dump($anyVariableYouMayWantToDump) | ||
| + | </ | ||
| + | |||
| + | Native PHP. | ||
| + | Basically echoes any variable with all its details to whatever interface you're working on. Great to see what actual data you get from something like an API. | ||
| + | |||
| + | ===== Memory Usage functions ===== | ||
| + | |||
| + | Theres functions in PHP to measure and display your current and your peak memory usage: | ||
| + | |||
| + | <code php> | ||
| + | $memoryCurrentlyUsed = memory_get_usage(true) // The parameter makes it take the real allocated usage | ||
| + | |||
| + | $memoryPeakUsage = memory_get_peak_usage(true) // These will give back an int value of bytes used | ||
| + | |||
| + | memory_reset_peak_usage() // Needs to be run to reset the peak usage, if needed | ||
| + | </ | ||
programmieren/php/wichtigefunktionen.1785485997.txt.gz · Last modified: by admin
