Salagir's Blog

Bon le blog est devenu tout simple tout moche, mais j’ai passé 24h à le mettre à jour. Il a peu de visites. Son ancien design n’était pas foufou. On va en rester là, hein. C’est surtout du texte après tout.

PHP functions reminder

I love PHP, but when it comes to consistency, it sucks very very very hard.

I’m tired of going to the (very very good) php.net site to check functions arguments and order and such, so now, all what I usually check will be here.
Nothing here is « complete ». My goal isn’t to make a doc, but a reminder of what I use.

Order of arguments in string/array functions

strpos ( $content , $search );
str_replace ( $search, $replace, $content );

array_search ( $search, $array);
in_array ( $search, $array);

.

Beloved classic flags

Flags I use all the time and won’t learn by heart.

preg_split ( $pattern, $content , -1, PREG_SPLIT_NO_EMPTY);
file ( $filename, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES );

.

The table of ob_start() (output buffering) related functions !

Empty buffer

Flush(=write) buffer

Returns buffer

Stop buffering
ob_clean()

YES

ob_end_clean()

YES

YES
ob_end_flush()

YES

YES

YES
ob_flush()

YES

YES

ob_get_clean()

YES

YES

YES
ob_get_contents()

YES

ob_get_flush()

YES

YES

YES

YES

ob_get_contents() should be named ob_get(). But you know… php and naming conventions…. T_T


Commentaires

Laisser un commentaire

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *