User Tools

Site Tools


programmieren:php:wichtigefunktionen

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
programmieren:php:wichtigefunktionen [2026/07/31 10:19] – created adminprogrammieren: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://www.php.net/manual/en/ref.array.php|list of array functions]]. Theres actually so much you can do with arrays and those functions in base PHP where you don't have access to collections etc. And knowing how to use them is very important. 
 + 
 +<code php> 
 +$array = array_merge_recursive(...$array) 
 +</code> 
 + 
 +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) 
 +</code> 
 + 
 +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) 
 +</code> 
 + 
 +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 
 +</code> 
programmieren/php/wichtigefunktionen.1785485997.txt.gz · Last modified: by admin

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki