Jump to content

trq

Staff Alumni
  • Posts

    30,999
  • Joined

  • Last visited

  • Days Won

    26

Everything posted by trq

  1. No. No, public can be accessed from anywhere.
  2. This topic has been moved to Application Frameworks. http://www.phpfreaks.com/forums/index.php?topic=323395.0
  3. class a { protected $var = 'foo'; } class b extends a { public function test() { echo $this->var; } } $b = new b; $b->test();
  4. What exactly is the problem?
  5. Ive never used Pear Mail but its just a php class, so yeah, you can simply include the file and use it. You might want to check the source though as it might actually rely on other code (Pear Error in particular comes to mind). Any classes it relies on will also be needed.
  6. This basically means your query has failed for some reason, and because you don't check this and just carry on, you get an error. The moral of the story here? If something can fail, check to make sure it hasn't before using any result you assume it has returned. [code=php:0] if ($sql_list = mysql_query($sql_clean)) { if (mysql_num_rows($sql_list)) { while($row = mysql_fetch_assoc($sql_list)) { $directory = "complete/" . $row['fileurl']; rrmdir($directory); } } else { // no result found. } } else { trigger_error(mysql_error()); }
  7. This topic has been moved to mod_rewrite. http://www.phpfreaks.com/forums/index.php?topic=323272.0
  8. This is all covered in the docs. http://codex.wordpress.org/Contributing_to_WordPress#Development_and_Testing
  9. This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=323229.0
  10. The best way you can do that is to pass one object into the another.
  11. Simple syntax errors really aren't something you should be posting on help forums about, your now missing a closing } If you indent your code these error will stand out.
  12. That would be '5 minutes prior to' not 'before 5 minutes'. $date = date("d-M-Y h:i:s", strtotime('-5 minutes'));
  13. Your missing a ; off of $login=$_GET["login"]
  14. Seriously, your not making allot of sense. If you include the same file twice and that file contains function or class definitions you WILL get errors because you cannot redeclare functions or classes. As for this.... <?php include 'lang.php'; include 'a.php'; include 'b.php'; $global = new lang(); /* Can another class use this? */ $a = new a(); echo $a->returnValue(); $b = new b(); echo $b->returnValue(); ?> Yes. Pass $global into the __construct of the object that need's it. I would however make sure you define a known interface firstly. Don't even mention globals and class / objects together.
  15. before 5 minutes? That makes NO sense.
  16. I'm not sure you actually read the op's problem here jamesxg1.
  17. Where possible you should try and pack (and I mean pack, using jsmin or similar) all your js into 1 file anyway. It makes for less http requests.
  18. Are you using the render() method like in my example? Can we see your code?
  19. If there in an array or something you could quickly populate the object using a method like..... public function setValues(array $values) { $this->_data = array_merge($values, $this->_data); }
  20. I very much doubt that phpBB is a good place to learn from. Most forum software has terrible code. In fact, for the amount of open source PHP applications around, there is very little that is particularly well written.
  21. Then you need to make sure its defined. An easy way to do this if you where using an mvc approach, or even just a simple bit of OOP would be to store all your variables within an object (View), this way you can easily make sure to return something. <?php class View { private $_data = array(); public function __set($name, $value) { $this->_data[$name] = $value; } public function __get($name) { if (isset($this->_data[$name])) { return $this->_data[$name]; } return NULL; } public function render($template) { ob_start(); include $template; echo ob_get_clean(); } } Now, lets say you have the a template: example.php <html> <head> <title><?php echo $this->title; ?></title> </head> <body> <p><?php echo $this->foo; ?></p> </body> </html> Even if the variable 'foo' isn't defined you wont get any error because it will just return NULL. <?php $v = new View; $v->title = 'this is an example'; $v->render('example.php'); Of course this idea can be extended quite a bit but it's a start.
×
×
  • 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.