Objektorientiert

master
Helge 2022-01-08 22:43:50 +01:00
parent 58e9a25332
commit 732893fa5e
1 changed files with 20 additions and 1 deletions

View File

@ -19,6 +19,25 @@ catch(PDOException $e)
echo $sql . "<br>" . $e->getMessage(); 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'; $url = 'https://therealblue.de';
$name = 'therealblue.de'; $name = 'therealblue.de';
@ -32,6 +51,6 @@ $sql = "SELECT * FROM link";
foreach ($pdo->query($sql) as $row) { foreach ($pdo->query($sql) as $row) {
echo '<a href="'.$row['link_url'].'" target="_blank">'.$row['link_name'].'</a><br>'; echo '<a href="'.$row['link_url'].'" target="_blank">'.$row['link_name'].'</a><br>';
} }
*/
?> ?>