|
|
|
|
|
|
php-snippets
|
|
|
PHP-Bereich
|
|
|
<?php ?>
|
|
|
|
|
|
|
|
|
isSet
|
|
|
if ( isset($_GET['number1']) ){ // Ist gesetzt?
$str_number1 = $_GET['number1']; } else { $ok = false; $errortext.="Error: The param 'number1' are not passed"; } // global $ok $errortext
function checkIssetInt($bez) {
global $ok; global $errortext; $zahl = 0; if (isset($_GET[$bez])) { // Ist gesetzt? $str_zahl = $_GET[$bez]; if (is_numeric($str_zahl)) { $zahl = intval( $str_zahl, 10); } else { $ok = false; $errortext.= "Error in number conversion: the variable '$bez' is not any number"; } } else { $ok = false; $errortext.= "Error: The param '$bez' are not passed"; } return $zahl; }
// global $ok $errortext
function checkIssetFloat($bez) {
global $ok; global $errortext; $zahl = 0.0; if (isset($_GET[$bez])) { // Ist gesetzt? $str_zahl = $_GET[$bez]; if (is_numeric($str_zahl)) { $zahl = floatval( $str_zahl); } else { $ok = false; $errortext.= "Error in number conversion: the variable '$bez' is not any number"; } } else { $ok = false; $errortext.= "Error: The param '$bez' are not passed"; } return $zahl; }
isSet Multiple
// the name of the select ui-element must have a '[]' $liste = array(); if ( isset($_GET['liste']) ){ // Is the list gesetzt? foreach ($_GET['prfs'] as $item) { $liste[] = $item; } } else { $ok =false; $errortext.="Error: Der Parameter 'liste' wurde nicht übergeben"; }
|
|
|
|
|
|
|
|
|
is_numeric
|
|
|
is_numericINT
if (is_numeric($str_number1)) { $number1 = intval ( $str_number1, 10 ); } else { $ok = false; $errortext.="Error in number conversion: the variable 'number1' is not any number"; }is_numericFLOAT
if (is_numeric($str_number1)) { $number1 = intval ( $str_number1, 10 ); } else { $ok = false; $errortext.="Error in number conversion: the variable 'number1' is not any number"; }
|
|
|
|
|
|
|
|
|
if $Ok Error
|
|
|
if($ok) { } else{ echo '<h2>Fehler</h2>'; echo $errortext; }
|
|
|
|
|
|
|
|
|
JSon
|
|
|
echo json_encode(...);
|
|
|
|
|
|
|
|
|
Class
|
|
|
class Result {
public $zahl=0; public $errortext=''; public $isError=false; } class Number {
public $zahl=0; public function __construct($zahl) { $this->zahl = $zahl; } }
|
|
|
|
|
|
|
|
|
Weiterleitung
|
|
|
header('location:nextHtml.xhtlm'); exit(1);
|
|
|
javascript-snippets
jsp-snippets
|
|
|