Sehr kurze Auszug: PHP isset_post ()

Oft haben zu prüfen, ob eine Variable mit dem POST gesendet wurde, und wenn nicht, einen Standardwert zuweisen. Statt mit der Syntax:

1
isset ( $_POST [ 'var_post' ] ) ? $_POST [ 'var_post' ] : default ; $ Miavar = isset ($ _POST ['var_post']) $ _POST ['var_post']: default;?

könnte eine Service-Funktion verwenden, wie:

1
2
3
4
5
6
7
8
9
10
/ **
* Prüfen, ob ein POST-Variablen vorhanden ist, sonst
* Legt ein Standardwert
*
* @ Param $ id_post ID der Variablen POST
* @ Param $ default (optional) Wert der Variablen zugewiesen werden, wenn nicht gesetzt
* /
$id_post , $default = '' ) { isset_post Funktion (id_post $, $ default ='') {
isset ( $_POST [ $id_post ] ) ? $_POST [ $id_post ] : $default ) ; return ( isset ($ _POST [$ id_post]) $ _POST [$ id_post]: $ default);
}

So wie zu erhalten:

1
2
3
isset_post ( 'var_post' ) ; Miavar isset_post = $ ('var_post');
/ / Oder
isset_post ( 'var_post' , 'valore di default' ) ; Miavar isset_post = $ ('var_post', 'default');

Es gibt keine Kommentare für diesen Beitrag

Hinterlasse einen Kommentar

XHTML TAG PERMIT: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> INSERTION CODE:
 <pre></pre> // blocco generico <code></code> // blocco generico [cc_actionscript][/cc_actionscript] // Actionscript [cc_actionscript3][/cc_actionscript3] // Actionscript 3 [cc_css][/cc_css] // CSS Style Sheet [cc_html][/cc_html] // HTML [cc_js][/cc_js] // Javascript [cc_objc][/cc_objc] // Objective-C [cc_php][/cc_objc] // PHP [cc_sql][/cc_sql] // SQL