2 Replies - 403 Views - Last Post: 23 June 2011 - 10:39 AM Rate Topic: -----

#1 E_Geek  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 45
  • View blog
  • Posts: 236
  • Joined: 20-February 11

Class $this->

Posted 23 June 2011 - 10:08 AM

Hey,

Is there any difference between $this->link and $this->_link ?
(link being a pdo connection)

Also, is there a difference between
$this->link->prepare()
And:

$this->_link->prepare()


Is This A Good Question/Topic? 0
  • +

Replies To: Class $this->

#2 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6106
  • View blog
  • Posts: 23,654
  • Joined: 23-August 08

Re: Class $this->

Posted 23 June 2011 - 10:15 AM

link and _link are two different variables, aren't they?

<?php

class Link
{
    public function __construct($link, $_link)
    {
        $this->link = $link;
        $this->_link = $_link;
    }

    public function printLinks()
    {
        echo "{$this->link} {$this->_link}\n";
    }
    private $link;
    private $_link;
}

$l = new Link("link1", "link2");
$l->printLinks();



php -f link.php 
link1 link2


Was This Post Helpful? 2
  • +
  • -

#3 E_Geek  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 45
  • View blog
  • Posts: 236
  • Joined: 20-February 11

Re: Class $this->

Posted 23 June 2011 - 10:39 AM

Ah, you've cleared that up for me, was wondering why there was no documentation on it :|

I honestly don't know why I've used $this->_link half the occurrences and $this->link for the rest :S
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1