Okay so how would this be accomplished in PHP? I want to make a simple object.Code://JS
var Obj = new Object();
Printable View
Okay so how would this be accomplished in PHP? I want to make a simple object.Code://JS
var Obj = new Object();
You would use classes 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.
Code:var theObject = {};
Oh I thought there was something like $stdobj.
I know about the JS, same with arrays. use ( = [] ) instead of ( = new Array(); )
There is. One of the basic variable types is object. Here's a little example.
Yes, literals can be used with arrays [] as well as objects {}.PHP Code: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;
Oh ok, thanks, that helped.