Jump to content

Archived

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

scottybwoy

varry simple var question ? *SOLVED*

Recommended Posts

example :

var $myTextColor = 'red';

is var depreciated and is it even needed?  Can it be used like so :

$myTextColor = 'red';

Thanks

Share this post


Link to post
Share on other sites
In a class the var is needed other wise get rid of it ok.


link might help.

http://uk.php.net/oop

example from link.
[code]
<?php
class Cart {
  /* None of these will work in PHP 4. */
  var $todays_date = date("Y-m-d");
  var $name = $firstname;
  var $owner = 'Fred ' . 'Jones';
  /* Arrays containing constant values will, though. */
  var $items = array("VCR", "TV");
}

/* This is how it should be done. */
class Cart {
  var $todays_date;
  var $name;
  var $owner;
  var $items = array("VCR", "TV");

  function Cart() {
      $this->todays_date = date("Y-m-d");
      $this->name = $GLOBALS['firstname'];
      /* etc. . . */
  }
}
?> 
[/code]

Share this post


Link to post
Share on other sites

×

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.