Jump to content

beginner question


Dermon3

Recommended Posts

Hi all

For example if you see this code:

 

    public function __set($varName,$varValue)

    {

        $this->$varName = $varValue;

        if ($varName == "varOne") {

            $this->varTwo = $this->varOne * 9;

        }

    }

 

Why somewhere dollar sign exists and somewhere not:

$this->$varName , $this->varTwo

?

Thanks

Link to comment
https://forums.phpfreaks.com/topic/227291-beginner-question/
Share on other sites

class model {

protected $_model;

function __construct($model) {

	$this->_model = $model;

	$this->$model =&new $model;

}

 

I think this is a simpler example of what is above. Your just using a variable to set the name of the model, Right? If not how is that wrong and if it is why?

 

This isn't something I am 100% confident on so I am asking too.

Link to comment
https://forums.phpfreaks.com/topic/227291-beginner-question/#findComment-1172435
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.