note 86617 added to language.types

From: Date: Sun, 26 Oct 2008 18:31:06 +0000
Subject: note 86617 added to language.types
Groups: php.notes 
Request: Send a blank email to php-notes+get-145779@lists.php.net to get a copy of this message
The Object (compound) Type Like every programming language, PHP offers the usual basic primitive types which can hold only one piece of data at a time (scalar). I am particularly fond of the "object" type (compound) because that allows me to group many basic PHP types together, and I can name it anything I want. <?php class Person { $firstName; // a PHP String $middleName; // a PHP String $lastName; // a PHP String $age; // a PHP Integer $hasDriversLicense; // a PHP Boolean } ?> Here, I have grouped several basic PHP types together, (3) Strings, (1) Integer, and (1) Boolean... then I named that group "Person". Since I used the proper syntax to do so, this code is pure PHP, which means that if you run this code, you would have an extra PHP "type" available to you in your scripts, like so: <?php $myAge = 16; // a PHP Integer - always available $yourAge = 15.5; // a PHP Float - always available $hasHair = true; // a PHP Boolean - always available $greeting = "Hello World!" // a PHP String - always available $person = new Person(); // a PHP Person - available NOW! ?> You can make your own object types and have PHP execute it as if it were part of the PHP language itself. See more on classes and objects in this manual at: http://www.php.net/manual/en/language.oop5.php ---- Server IP: 209.41.74.194 Probable Submitter: 67.150.124.6 ---- Manual Page -- http://www.php.net/manual/en/language.types.php Edit -- https://master.php.net/note/edit/86617 Del: integrated -- https://master.php.net/note/delete/86617/integrated Del: useless -- https://master.php.net/note/delete/86617/useless Del: bad code -- https://master.php.net/note/delete/86617/bad+code Del: spam -- https://master.php.net/note/delete/86617/spam Del: non-english -- https://master.php.net/note/delete/86617/non-english Del: in docs -- https://master.php.net/note/delete/86617/in+docs Del: other reasons-- https://master.php.net/note/delete/86617 Reject -- https://master.php.net/note/reject/86617 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#145779) next »