Exemple #1
0
<?php

class Student
{
    private $full_name = '';
    private $score = 0;
    private $grades = array();
    public function __construct($full_name, $score, $grades)
    {
        $this->full_name = $full_name;
        $this->grades = $grades;
        $this->score = $score;
    }
    public function show()
    {
        echo $this->full_name;
    }
    public function __wakeup()
    {
        echo 'Esperando ...';
    }
}
$student = new Student('Frank Sanchez', 'a', array('a' => 90, 'b' => 100));
$student->show();
echo "<br>";
$s = serialize($student);
echo '<br>' . $s . '<br>';
?>

Exemple #2
0
<?php

require_once '../init.php';
$student = new Student(new PDOdb("mysql:host=localhost;dbname=usjr", "root", ""));
$results = $student->show('studlname');
?>
<!DOCTYPE html>
<html lang="en">
   <head>
      <meta charset="UTF-8">
      <meta author="Rabsky">
      <title>
         Student Management - Listing  
      </title>
      <link rel="stylesheet" type="text/css" href="../css/ustyles.css">
   </head>
   <body>
      <header class="mainheader">
         <section class="lefthead">
             <span class="headtext">Rabsky University</span>
         </section>
         <section class="righthead">
         </section>
      </header>   
     <?php 
if ($results) {
    ?>
 	      <table name="studlisting" class="studlist">
 	         <tr>
 	         	<td>ID</td>
 	         	<td>Name</td>
Exemple #3
0
<?php

require_once "init.php";
//echo "i am here";
$student = new Student(new PDOdb("mysql:host=localhost;dbname=usjr", "root", ""));
$result = $student->show();
if (!$result) {
    echo "No data contained in the result set...";
} else {
    foreach ($result as $res) {
        echo $res['studid'] . ' ' . $res['studfname'] . ' ' . $res['studlname'] . "<br>";
    }
}
// $studid     = 'AA-002';
// $studfname  = 'Jeoffrey';
// $studlname  = 'Gudio';
// $studmname  = 'Camocamo';
// $studcourse = 'BSIT';
// $studyear   = 4;
// $result = $student->insert(array($studid,$studfname,
// 	                        $studlname,$studmname,$studcourse,$studyear));
// if($result > 0)
// 	 echo "Data added";
// else
//      echo "Data was not added";
$result = $student->update(array('studid' => 'AA01', 'studfname' => 'Jeoffrey'), array('studlname' => 'Gudio', 'studcourse' => 'BSCS'), 2);
echo $result;
if ($result > 0) {
    echo "Operation done";
} else {
    echo "Operation failed";
    }
    public function __destruct()
    {
    }
    public function show()
    {
        parent::show();
        echo "Ocena: " . $this->ocena . "</br>";
    }
}
echo "<h3>Obiekty przed serializacja:</h3>";
$obiekt1 = new Osoba("Jan", "Kowalski", 92112425435);
$obiekt1->show();
echo "</br>";
$obiekt2 = new Student("Grzegorz", "Więckowski", 90042135221, 4.23);
$obiekt2->show();
echo "<h3>Obiekty po serializacji:</h3>";
$obiekt1_serial = serialize($obiekt1);
echo "</br>";
echo $obiekt1_serial;
echo "</br>";
echo "Nie jest mozliwe wywołanie metod obiektow serializowanych.";
echo "</br>";
//$obiekt1_serial->show();
$obiekt2_serial = serialize($obiekt2);
echo "</br>";
echo $obiekt2_serial;
echo "</br>";
echo "Nie jest mozliwe wywołanie metod obiektow serializowanych.";
echo "</br>";
//$obiekt2_serial->show()