Objektorientiert
parent
58e9a25332
commit
732893fa5e
21
index.php
21
index.php
|
@ -19,6 +19,25 @@ catch(PDOException $e)
|
|||
echo $sql . "<br>" . $e->getMessage();
|
||||
}
|
||||
|
||||
|
||||
// Versuch der Objektorientierung
|
||||
|
||||
class Link{
|
||||
public $name;
|
||||
public $url;
|
||||
|
||||
public function __construct($newName, $newUrl){
|
||||
$this->name = $newName;
|
||||
$this->url = $newUrl;
|
||||
}
|
||||
}
|
||||
|
||||
$link1=new Link("therealblue.de", "https://therealblue.de");
|
||||
|
||||
echo '<a href="'.$link1->url.'" target="_blank">'.$link1->name.'</a><br>';
|
||||
|
||||
/* Alt vor Obejktorientierung
|
||||
|
||||
$url = 'https://therealblue.de';
|
||||
$name = 'therealblue.de';
|
||||
|
||||
|
@ -32,6 +51,6 @@ $sql = "SELECT * FROM link";
|
|||
foreach ($pdo->query($sql) as $row) {
|
||||
echo '<a href="'.$row['link_url'].'" target="_blank">'.$row['link_name'].'</a><br>';
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
?>
|
Loading…
Reference in New Issue