AutoNav?

PHP Evaluation

Language

PHP -  http://www.php.net/

Prerequisites

none

Installation

Simple Class definition

Project Creation

create a folder "Talker" create a file "talker.php" create a file "main.php"

Execution

Run from Command Line

  • cmd> php main.php

Run within an Interactive Environment

  • cmd> ?

talker.php

define a class "Talker"

// within file "talker"

class Talker {
  function sayHello() {
    echo "Hello world";
  }

# Simple Variable Access 

private $name;
private $age;

function __get($name) {
  return $this->vars[$name];
}

function __set($name, $value) {
  $this->vars[$name] = $value;
}

function __get($age) {
  return $this->vars[$age];
}

function __set($age, $value) {
  $this->vars[$age] = $value;
} 


function sayYourName() {
  echo $this->name;
} 

function sayYourAge() {
  echo $this->age;
} 

# Simple Reflective Data Access 

function sayYourClassName() {
  echo __CLASS__;
} 

# Reflection, Advanced

function thisMethodName() {
  echo "???";
} 

function sayHelloAdvanced() {
  echo thisMethodName() + "Hello World";
} 

# Reflection, Expert

function sayYourClassDefinition() {
  echo "LIMITATION: Class Definition not available";
}

function sayYourClassCode() {
  echo "LIMITATION: Class Code not available";
} 

function sayYourInstanceVarName() {
  echo "LIMITATION: instance variable name not available";

}

# Metadata
# Apply Metadata to any Object (Classes, Object Intances, Variables, Methods)

//??? 

main.php

// within file "main"

require 'talker.php';

$john = new Talker();
$john->sayHello(); 

john.name = "John Doe php";
john.age = 19;
john->sayYourName();
john->sayYourAge(); 

john->sayYourClassName();

john->sayHelloAdvanced();

john->sayYourClassDefinition();
john->sayYourClassCode();
john->sayYourInstanceVarName();