<!DOCTYPE html> <?php require_once 'class/class.php'; $datos = new Prueba(); $id_usuario = isset($_GET['id_usuario']) ? $_GET['id_usuario'] : null; $nombres = isset($_GET['nombres']) ? $_GET['nombres'] : null; $apellidos = isset($_GET['apellidos']) ? $_GET['apellidos'] : null; $op = isset($_GET['op']) ? $_GET['op'] : null; if (isset($op) and $op == "Editar") { $datos->updateUsuario(); } ?> <html> <head> <title></title> </head> <body> <h1>Editar Usuario</h1> <form method="GET" action="index.php"> <input type="hidden" name="id_usuario" value="<?php echo $id_usuario; ?> "> <label>Nombres</label><input type="text" name="nombres" value="<?php echo $nombres; ?> "> <label>Apellidos</label><input type="text" name="apellidos" value="<?php echo $apellidos; ?> ">
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer the ID of the model to be loaded */ public function loadModel($id) { $model = Prueba::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
<?php require_once 'class/class.php'; $id_usuario = $_GET['id_usuario']; $op = $_GET['op']; $datos = new Prueba(); if (isset($op)) { $datos->delUsuario($id_usuario); echo "<script>\n\t\t\twindow.location='index.php';\n\t\t</script>\n\t\t"; }
{ $this->initialTime = microtime(true); } protected function timeElapsed() { $otro = "initialTime"; echo $this->{$otro}; echo "\n"; echo $this->initialTime; $timeElapsed = $this->timeEnd(); $timeElapsed = $timeElapsed - $this->{$otro}; } protected function timeEnd() { $timeEnd = microtime(true); return $timeEnd; } } function setStartTime() { } class Prueba extends ExecuteTime { public function mesuaredFunction() { echo "test"; } } $prueba = new Prueba(); $prueba->calculateTimeOfExecution(); include "php1.php";
class prueba { function test(Alan $alan, Book $book, array $array) { echo "metodo de prueba clase prueba"; } } function test(Alan $alan, Book $book, array $array) { echo "metodo de prueba normal"; } class Alan { } class Book { } $array = array(1, 2, 3, 4, 5); $prueba = new Prueba(); $alan = new Alan(); $book = new Book(); $prueba->test($alan, $book, (array) "stringPrueba"); echo "<br/>"; test($alan, $book, $array); //casos //1. se mandaron los parametros especificados => se tuvo los resultados esperados //2. no se mando el array => te tira un catchable fatal error el argumento 3 debe de ser de tipo array //3. se mandaron 2 books en vez de un 1 alan => catchable error argument debe de ser de tipo Alan //4. se mando una cadena en vez de un arreglo => catchable error argument debe ser un array. //5. se mando una cadena en vez de un arreglo pero se casteo a array => todo funciona normal
<?php //error_reporting(E_ALL ^ E_NOTICE); require_once 'class/class.php'; $datos = new Prueba(); $id_usuario = isset($_GET['id_usuario']) ? $_GET['id_usuario'] : null; $nombres = isset($_GET['nombres']) ? $_GET['nombres'] : null; $apellidos = isset($_GET['apellidos']) ? $_GET['apellidos'] : null; $op = isset($_GET['op']) ? $_GET['op'] : null; if (isset($op) and $op == "del") { $datos->delUsuario($id_usuario); } if (isset($op) and $op == "Editar") { $datos->updateUsuario(); } if (isset($nombres) && isset($apellidos)) { $datos->addUsuario(); } ?> <html> <head> <title> Usuarios </title> </head> <body> <h1>Usuarios</h1> <form method="GET" action="index.php"> <label>Nombres</label><input type="text" name="nombres"> <label>Apellidos</label><input type="text" name="apellidos"> <input type="submit" value="Insertar">
<?php class Prueba { public static function getNew() { return new static(); } } class Hija extends Prueba { } $obj1 = new Prueba(); $obj2 = new $obj1(); var_dump($obj1 !== $obj2); $obj3 = Prueba::getNew(); var_dump($obj3 instanceof Prueba); $obj4 = Hija::getNew(); var_dump($obj4 instanceof Hija);
<?php require_once 'class/class.php'; ?> <html> <head> <title> Detalle de usuario </title> </head> <body> <h1>Detalle de usuario</h1> <?php $datos = new Prueba(); $result = $datos->getUsuarioId(); foreach ($result as $row) { echo $row['id_usuario'] . "<br>"; echo $row['nombres'] . "<br>"; echo $row['apellidos'] . "<br>"; } ?> </body> </html>