Jump to content




PHP Function/Variable/Thingy Help


  • You cannot reply to this topic
2 replies to this topic

#1 Imque

  • Members
  • 134 posts

Posted 29 June 2013 - 05: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.

#2 Apfeldstrudel

  • Members
  • 161 posts

Posted 29 June 2013 - 10:33 AM

Ask a pro?

#3 Engineer

  • Members
  • 1,378 posts
  • LocationThe Netherlands

Posted 29 June 2013 - 04:48 PM

View PostXyexs, on 29 June 2013 - 10:33 AM, said:

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/manua...nguage.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/manua...e.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






2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users