Ejercicio:
<?php
//ESTA ES SINTAXIS ANTIGUA
/*class Course
{
public $title;
public $subtitle;
public $description;
public $tags;
public function __construct($title, $subtitle, $description, $tags)
{
$this->title = $title;
$this->subtitle = $subtitle;
$this->description = $description;
$this->tags = $tags;
}
}
$course = new Course(
'Curso Profesional de PHP y Laravel',
'Aprende PHP y LARAVEL desde cero',
'Lorem ipsum dolor sit amet consectetur adipisicing elit. Maiores quibusdam unde modi incidunt. Voluptatem tenetur aliquam, expedita vitae libero vel ullam sequi aspernatur, ad cum unde et voluptates consequuntur dolorem!',
['Curso de HTML', 'Curso de PYTHON', 'Curso de LARAVEL', 'Curso de GITHUB'],
);*/
class Course
{
public function __construct(
public string $title,
public string $subtitle,
public string $description,
public array $tags
) {
// Aqui construimos el codigo
}
}
$course = new Course(
title: 'Curso Profesional de PHP y Laravel',
subtitle: 'Aprende PHP y LARAVEL desde cero',
description: 'Lorem ipsum dolor sit amet consectetur adipisicing elit. Maiores quibusdam unde modi incidunt. Voluptatem tenetur aliquam, expedita vitae libero vel ullam sequi aspernatur, ad cum unde et voluptates consequuntur dolorem!',
tags: ['Curso de HTML', 'Curso de PYTHON', 'Curso de LARAVEL', 'Curso de GITHUB']
);
class Autor
{
public function __construct(
public string $nombre,
public string $apellido,
public string $email,
public string $pais,
public string $biografia,
public array $redesSociales = ['twiter', 'facebook', 'github'],
) {
}
}
$autor = new Autor(
nombre: "Nombre: Peter",
apellido: "Apellido: García",
email: "Email: peter@example.com",
pais: "Pais: España",
biografia: "Biografia: Desarrollador web apasionado por PHP y Laravel.",
redesSociales: [
"twitter" => "@peterdev",
"facebook" => "petersib"
//"github" => "github.com/peterdev"
]
);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><?php $course->title ?></title>
<style>
body {
margin: 0;
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
background: linear-gradient(135deg, #ece9e6, #ffffff);
font-family: Arial, Helvetica, sans-serif;
}
.container1 {
width: 650px;
min-height: 520px;
background: #fff;
padding: 30px;
border-radius: 12px;
box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
text-align: center;
}
h1 {
margin-top: 0;
font-size: 28px;
color: #333;
}
.sub-title {
font-size: 20px;
color: #0077cc;
margin-bottom: 20px;
}
p {
color: #444;
line-height: 1.6;
}
.etiquetass {
text-align: left;
margin-top: 20px;
}
.etiquetass ul {
list-style: none;
padding-left: 0;
}
.etiquetass li {
background: #f0f8ff;
margin-bottom: 8px;
padding: 8px 12px;
border-radius: 6px;
border-left: 4px solid #0077cc;
font-weight: bold;
}
</style>
</head>
<body>
<!-- Forma antigua -->
<!--<div class="container1">
<h1>Bienvenido al <?= $course->title ?></h1>
<h2 class="sub-title"><?= $course->subtitle ?></h2>
<p><?= $course->description ?></p>
<div class="etiquetass">
<strong>Etiquetas:</strong>
<ul>
<?php foreach ($course->tags as $tag): ?>
<li><?= $tag ?></li>
<?php endforeach; ?>
</ul>
</div>-->
<!-- Forma profesional -->
<!--<div class="container1">
<h1>Bienvenido al <?= $course->title ?></h1>
<h2 class="sub-title"><?= $course->subtitle ?></h2>
<p><?= $course->description ?></p>
<div class="etiquetass">
<strong>Etiquetas:</strong>
<ul>
<?php foreach ($course->tags as $tag): ?>
<li><?= $tag ?></li>
<?php endforeach; ?>
</ul>
<div>
</div>-->
<!-- Ejercicio -->
<div class="container1">
<h1>Bienvenido al <?= $course->title ?></h1>
<h2 class="sub-title"><?= $course->subtitle ?></h2>
<p><?= $course->description ?></p>
<div class="etiquetass">
<strong>Autor:</strong>
<p><?= $autor->nombre ?></p>
<p><?= $autor->apellido ?></p>
<p><?= $autor->email ?></p>
<p><?= $autor->pais ?></p>
<p><?= $autor->biografia ?></p>
<ul>
<?php foreach ($autor->redesSociales as $redesSociales): ?>
<li><?= $redesSociales ?></li>
<?php endforeach; ?>
</ul>
<div>
</div>
</body>
</html>