assignment4 - PHP Online
Form of PHP Sandbox
Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php
in the places where the PHP script should be executed.
Result of php executing
Full code of assignment4.php
- <?php
- class Persona {
- public $name;
- public $arcana;
- public $level;
- function __construct($x, $y, $z){
- $this->name = $x;
- $this->arcana = $y;
- $this->level = $z;
- }
- function get_name(){
- return $this->name;
- }
- function get_arcana(){
- return $this->arcana;
- }
- function get_level(){
- return $this->level;
- }
- }
- $Ippon_Datara = new Persona("Ippon-Datara", "Hanged", 13);
- $Thunderbird = new Persona("Thunderbird", "Sun", 35);
- $Fafnir = new Persona("Fafnir", "Hermit", 86);
- $myArray = array();
- array_push($myArray, $Ippon_Datara, $Thunderbird, $Fafnir);
- $output = "";
- $output .= '<TABLE border="2">';
- $output .= '<tr>';
- $output .= '<th>' . "Name" . '</th>';
- $output .= '<th>' . "Arcana" . '</th>';
- $output .= '<th>' . "Level" . '</th>';
- $output .= '</tr>';
- foreach($myArray as $obj){
- $output .= "<tr>";
- $output .= "<td>" . $obj->get_name() . "</td>";
- $output .= "<td>" . $obj->get_arcana() . "</td>";
- $output .= "<td>" . $obj->get_level() . "</td>";
- $output .= "</tr>";
- }
- echo $output;
File Description
- assignment4
- PHP Code
- 09 Jul-2021
- 1.09 Kb
You can Share it:
Latest PHP Pastes