This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* gibt z.B. 'Am 05.03.2007 um 12:12 Uhr wurde die Datei geaendert.' aus. */ | |
$obj = Factory::create (__FILE__); | |
print $obj->repr (); | |
/* gibt 'Es ist ein Fehler aufgetreten!' aus */ | |
$obj = Factory::create ("nicht-existierende-datei"); | |
print $obj->repr (); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function scope_include ($file) { | |
if (is_file ($file)) { | |
include ($file); | |
return (get_defined_vars ()); | |
} | |
return (FALSE); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function getmicrotime () { | |
list ($usec, $sec) = explode(" ", microtime()); | |
return ((float)$usec + (float)$sec); | |
} | |
define ("TESTARRAY_MIN", 1); | |
define ("TESTARRAY_MAX", 10000); | |
define ("WINNERARRAY_MAX", 10); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$link = mysql_connect("mysql_host", "mysql_user", "mysql_password") | |
or die("Keine Verbindung möglich: " . mysql_error()); | |
echo "Verbindung zum Datenbankserver erfolgreich"; | |
mysql_select_db("Meine_Datenbank") or die("Auswahl der Datenbank fehlgeschlagen"); | |
$query = "SELECT * FROM Meine_Tabelle"; | |
$result = mysql_query($query) or die("Anfrage fehlgeschlagen: " . mysql_error()); | |
echo "<table>\n"; | |
while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
define('MySQL_DB_HOST', 'mysql_host'); | |
define('MySQL_DB_USER', 'mysql_user'); | |
define('MySQL_DB_PASSWORD', 'mysql_password'); | |
define('MySQL_DB_NAME', 'Meine_Datenbank'); | |
class MySQL { | |
var $conn; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
include_once ("db.php"); | |
$db = new MySQL; | |
$db->sql ("SELECT * FROM Meine_Tabelle"); | |
$result = $db->result (); | |
if (!empty ($result)) { | |
echo "<table>\n"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> class example(object): | |
__slots__ = ["x", "y", "z"] | |
>>> example = example() | |
>>> example.x = 0 | |
>>> example.y = '0' | |
>>> example.z = 'Null' | |
>>> example.a = 0 | |
Traceback (most recent call last): | |
File "", line 1, in ? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class slotObject { | |
function set ($input) { | |
$slot = array_keys (get_class_vars (get_class ($this))); | |
if (is_array ($input)) { | |
foreach ($input as $key => $value) { | |
if (in_array ($key, $slot)) { | |
$this->$key = $value; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class example extends slotObject { | |
var $x; | |
var $y; | |
var $z; | |
} | |
class exampleChild extends example { | |
var $a; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Factory { | |
function create ($file) { | |
if (file_exists ($file) && ($mtime = filemtime ($file))) { | |
return new CMtime ($mtime); | |
} | |
return new CError (); | |
} |