Jump to content

Search the Community

Showing results for tags 'object'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • New Member at General Forum?
    • Welcome Lounge
    • General Forum Announcements
    • Suggestions and Feedback
  • The General Forums
    • General Discussions
    • News Hub
    • Gamers Den
    • Sports & Entertainment
    • Techno Geeks Unite
    • The Marketplace

Blogs

There are no results to display.

Calendars

  • Community Calendar
  • Default Calendar

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


About Me


Location


Gender


Interests


Occupation


Xbox Live Gamertag

Found 1 result

  1. The Basics of OOP in PHP The language used for runescape private servers is Java, Java is scripted in OOP. When you look at OOP in PHP you'll probably see alot of similarity. The Class First you need to create a class. (Note The name must start with a capital letter) class MyFirstPage() { //Your methods here } In OOP PHP you have a constructor. The constructor is run immediately after the class is called. The custructor looks like this: public function __construct() { //What you want to run first } Like in Java you need to declare a variable before you can write to it or use it. Do that like this: public $var; Lets put it all to work! class MyFirstPage { protected $_name; protected $_age; public function __construct($name, $age) { $this->_name = $name; $this->_age = $age; } public function getName() { return $this->_name; } public function getAge() { return $this->_age; } } Now save that as MyFirstPage.php (Usually a class file is named after the class). Now lets make the page to let it show! include './MyFirstPage.php'; $myfirstpage = new MyFirstPage('Michael', '15'); //Change these values to make it use another name or age echo 'The name is: '. $myfirstpage->getName() .' and im: '. $myfirstpage->getAge() .' years old'; and save that as index.php Now upload index.php and MyFirstPage.php to your webhost and test it out! NOTE: You dont need to end the PHP file with ?> when the whole file is only PHP without HTML.
×
×
  • Create New...