code?
November 23rd, 2008, 06:59 PM
Okay so how would this be accomplished in PHP? I want to make a simple object. //JS
var Obj = new Object();
var Obj = new Object();
|
Click to See Complete Forum and Search --> : Basic Object code? November 23rd, 2008, 06:59 PM Okay so how would this be accomplished in PHP? I want to make a simple object. //JS var Obj = new Object(); PeejAvery November 24th, 2008, 09:39 AM You would use classes (http://us.php.net/oop) in PHP. This is where it gains the title as an object-oriented language. Also, in JavaScript, you should use string literals rather than the whole object. This allows you for creation of the member's methods and functions at the implementation of the actual object's definition. var theObject = {}; code? November 25th, 2008, 04:18 AM Oh I thought there was something like $stdobj. I know about the JS, same with arrays. use ( = [] ) instead of ( = new Array(); ) PeejAvery November 25th, 2008, 07:37 AM Oh I thought there was something like $stdobj. There is. One of the basic variable types is object. Here's a little example. class testClass { public $testVariable = 'Test method complete.'; function testMethod() { echo $this->testVariable; // class methods can access shared variables } } $testObject = new testClass(); $testObject->testMethod(); // outputs Test method Complete; I know about the JS, same with arrays. use ( = [] ) instead of ( = new Array(); ) Yes, literals can be used with arrays [] as well as objects {}. code? November 25th, 2008, 12:35 PM Oh ok, thanks, that helped. codeguru.com
Copyright Internet.com Inc., All Rights Reserved. |