|
php-Bereich
<?php
?>isset
if ( isset($_GET['vorname']) ){ // Ist gesetzt? $vorname = $_GET['vorname']; }
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; }
isnumeric
if (is_numeric($sZahl)) { $Zahl = intval ( $sZahl, 10 ); } else { echo "Error in number conversion: the variable '???' is no number", PHP_EOL; }
intval
$Zahl = intval ( $sZahl );
createArray
$feld = array();
addElement 2 Array
$feld[] = "newItem";
Anzahl der Elemente
$numberOfElements = count($feld)
foreach ($feld as $item) {
echo $item . '<br />'; }
attrib get/set
private $attrib; public function getattrib() { return $this->attrib; } public function setattrib($value) { $this->attrib=$value; }JSON
private function processArray($array) { foreach ($array as $key => $value) { if (is_object($value)) { $array[$key] = $value->toArray(); } // if if (is_array($value)) { $array[$key] = $this->processArray($value); } } // foreach // If the property isn't an object or array, leave it untouched return $array; }
public function toArray() { return $this->processArray(get_object_vars($this)); }
json encode
$ergebnis = json_encode($std->toArray());
regex
$match = '/^[A-ZÄÖÜ]{1,1}[a-zäüöß]{1,29}$/'; if(!preg_match($match, $lastname)) { echo 'Fehlerhafter Nachname'; }
Stringlänge
strlen($str); // String-length
echo
echo '<p>Hier kommt ein Text in der HTML-Datei</p>' . PHP_EOL;
|
|