Welcome Guest, Not a member yet? Register   Sign In
Class selector method question
#1

[eluser]Th3FalleN[/eluser]
What I am attempting to do is use selectors similar to this

Code:
Class::method()


instead of

Code:
$this->class->method()


for libraries but I keep receiving errors. I'm sure its something silly but I figured i'd ask the experts.
#2

[eluser]theprodigy[/eluser]
one is a variable instance, the other is a class reference.

$this->class = 'class' is a variable that CI creates when instantiating the class.
Class = the class name, not necessarily the variable representing an instance of the class
#3

[eluser]Th3FalleN[/eluser]
I saw it done in another ci project but could not figure out why it works over there. Say im using an asset library i'd like to be able to do is insted of
Code:
$this->assets->css('cssfile');
i'd like to be able to to do
Code:
Assets::css('cssfile');
any way that you know that that could be achieved?
#4

[eluser]theprodigy[/eluser]
You should be able to do that if you just include() or require() the file yourself, then the class would be in php's memory.

Either that or setup an autoload function to handle auto loading it into memory.
#5

[eluser]danmontgomery[/eluser]
One is static, one is not.

I'm confused why you're trying to do this without understanding the difference between the two, though

http://php.net/manual/en/language.oop5.static.php




Theme © iAndrew 2016 - Forum software by © MyBB