Jump to content

Daniel0

Staff Alumni
  • Posts

    11,885
  • Joined

  • Last visited

Everything posted by Daniel0

  1. Nightslyr, if you're checking that the string only contains letters and spaces, then it's a waste running it through mysql_real_escape_string() seeing as it obviously does not contain any characters which should be escaped.
  2. Hosts won't update within a few years anyways...
  3. True... not anymore though.
  4. Nah... I don't think those areas are large enough for that. I think we're pretty good covered with those four groups - at least for the time being.
  5. I'd be careful with that. Some applications are written poorly and beginner programmers will most likely not realize that when reading its code.
  6. You can do it here: http://phpfreaks.com/donations.php
  7. Imagine you need to write some classes which parse various types of configuration files. You could have Config_Ini and Config_Xml for instance. Both of these classes may have some common functionality, so you could put that in a class called Config. Config in itself doesn't work though, so it's an abstract class. abstract class Config { protected $data = array(); public function __construct($path) { if (file_exists($path)) { $this->parse(file_get_contents($path)); } else { throw new Exception("File {$path} could not be loaded"); } } public function __get($name) { return $this->data[$name]; } public function __set($name, $value) { $this->data[$name]; } public funtion __isset($name) { return isset($this->data[$name]); } public function __unset($name) { unset($this->data[$name]); } abstract protected function parse($data); } Then you can implement the type specific classes: class Config_Xml extends Config { protected function parse($data) { // do stuff here } } class Config_Ini extends Config { protected function parse($data) { // do stuff here } } This would be an example of how you could use abstract classes. As an example for using an interface you could imagine you have an interface called Iterator: interface Iterator { /** * Returns the value of the current item. */ public function current(); /** * Returns the key of the current item. */ public function key(); /** * Goes forward... */ public function next(); /** * Goes to the first item... */ public function rewind(); /** * Checks if the current position holds a valid value. */ public function valid(); } So by implementing this interface into a class, your code can be certain that it has implemented the methods specified in the interface. You could then have a function or method like this: function doStuff(Iterator $obj) { while ($obj->valid()) { echo "{$obj->key()} => {$obj->value()}<br />"; $obj->next(); } $obj->rewind(); } The function doesn't care what kind of object it is, it just needs to be iteratable (I don't know if that's a word). Note: PHP does actually have an interface called Iterator. If an object implements that interface then it'll be able to be used in a foreach loop (if I remember correctly).
  8. We have decided to remove the regular post-based ranks. To replace them we have created a number of guru groups: PHP Help OOP Databases Design The gurus are hand picked by the administrators, moderators and recommended members because they generally make quality posts in their specific areas. They will appear in a yellow-ish color on the online list and have ten stars: The first gurus are: PHP Help Gurus btherl, corbin, GingerRobot, MadTechie, Orio and play_ OOP Gurus dbo, Jenk, keeB We have not yet chosen any database or design gurus. Congratulations to the chosen ones.
  9. If you look at the file install.xml in the package, then you'll see that in $themedir/Display.template.php it searches for: 'move' => array('test' => 'can_move', 'text' => 132, 'image' => 'admin_move.gif', 'lang' => true, 'url' => $scripturl . '?action=movetopic;topic=' . $context['current_topic'] . '.0'), and inserts this after it: 'topic_solved' => array('test' => 'can_solve_topic', 'text' => $context['topic_solved'] ? 'topic_unsolved' : 'topic_solved', 'image' => 'topic_solved.gif', 'lang' => true, 'url' => $scripturl . '?action=topicsolved;topic=' . $context['current_topic'] . ';sesc=' . $context['session_id']), I guess you'll need to do something similar.
  10. Yes, but how do you determine that using your script? Also, is the problem that the user gets logged out randomly or is it that they're displayed as inactive although they are (sort of like the who's online list on this forum)?
  11. $_FILES is only populated once a file has been uploaded. I'm not sure what you're trying to do. See this page: http://php.net/file-upload
  12. Under what conditions are users deemed as inactive?
  13. <?php $array = range(1, 9); foreach ($array as $i => $item) { echo $item; if (($i+1) % 3 == 0) { echo "\n"; } else { echo ' | '; } } ?> 1 | 2 | 3 4 | 5 | 6 7 | 8 | 9
  14. Hmm... that's not the one we have installed. I don't think that package is up anymore. I have attached the one we're using. [attachment deleted by admin]
  15. I prefer Zend Framework because it's more flexible and it's extremely easy to add additional classes as well as extend functionality of existing classes. Those things appeal to me. There are a lot of sites using Zend Framework as well. Check out some of the case studies for instance. Furthermore, ZF has partnerships with large companies such as IBM, Google and Microsoft as well.
  16. I'm quite sure Chris was referring to whether he would use a framework or not. You'll end of preferring a particular framework anyways, so it would be pointless and a waste of time bothering to learn multiple frameworks.
  17. You'd loop through it using e.g. a while loop. Example: <?php $db = new PDO('mysql:dbname=test;host=localhost', 'root', ''); $result = $db->query('something'); while($row = $result->fetch()) { // do stuff } // or foreach($result->fetchAll() as $row) { // do stuff } ?> I used PDO here.
  18. So can the Location and Refresh headers. You cannot force the user to do anything at all. As in real life, just because you tell people to do something, it doesn't mean they will do it.
  19. Ah, sorry. I didn't realize that the third parameter is added in 5.3 which is not yet released. Try this instead: substr($string, 0, strpos($string, '\\')-1);
  20. If you always only need the thing before the first backslash, then you could do: strstr($string, '\\', true);
  21. It is PHP 5 syntax. I think aschk is referring to that you are not explicitly declaring the methods as public. However, if you omit a visibility declaration for a method, then it will always be public implicitly. It's standard practice to always include it though.
  22. str_pad(rand(0, 999999), '0', STR_PAD_LEFT); or sprintf('%06d', rand(0, 999999)); Also, if an integer starts with 0 in PHP then it will be considered octal, so you might get odd results if you start doing that.
  23. It would hold parent-child information. Instead of DarkWater's suggested database layout, I'd just remove the sub_cats table and have both category_id and subcategory_id in the cat_relation table reference an entry in the categories table.
  24. str_replace("\\TOLL FREE DIAL '1' & THEN\\", '', $string);
  25. Why bother learning multiple? Just take a look at the major ones and decide which one you like best. I like Zend Framework most and it is what the new site is being built with.
×
×
  • 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.