This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Imque's profile picture

PHP Function/Variable/Thingy Help

Started by Imque, 29 June 2013 - 04:29 AM
Imque #1
Posted 29 June 2013 - 06:29 AM
Hai,

I am been coding PHP a fair bit and have just found a function/variable thing that looks like this::



$table->engine


What is this called, I have seen it in IP.Board. (its called the 'registry' there)

I have had a look on google and cant find much.
Apfeldstrudel #2
Posted 29 June 2013 - 11:33 AM
Ask a pro?
Engineer #3
Posted 29 June 2013 - 05:48 PM
Ask a pro?
Since this is a ComputerCraft forum where we program in Lua, I can see why Imque chose the General section.

To answer the question: I honestly have no idea. But when I was searching for OOP in PHP, I came across this: http://php.net/manual/en/language.oop5.php
If you go to the basics section you get something similair, but Im not sure if that is the answer to the question.

Edit: Since Im interested enough, I kept googling. Shortly, I found this page: http://php.net/manual/en/language.operators.php
If you scroll down to the "User Contributed Notes Operators - [12 notes]" go ahead and find "pgarvin76+php dot net at NOSPAMgmail dot com"
And I think I was right, it has to due with OOP

It is method chaining, so if you are familair with lua OOP:

local object = {
   __index = object;
   create = function()
     local self = {
        number = 0;
        add = function( self )
           self.number = self.number + 1
           print( self.number )
           return self
        end;
        subtract = function( self )
           self.number = self.number - 3
           print( self.number )
           return self
        end;
     }
     return setmetatable( self, object )
   end
}

local newObject = object.create()

newObject:add():add():subtract()

print( newObject.number )
--#Outputs:
--# The chain:
--#    1 .. 2 .. -1
--# The print:
--#    -1