Daniel0
Staff Alumni-
Posts
11,885 -
Joined
-
Last visited
Everything posted by Daniel0
-
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.
-
Hosts won't update within a few years anyways...
-
True... not anymore though.
-
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.
-
I'd be careful with that. Some applications are written poorly and beginner programmers will most likely not realize that when reading its code.
-
You can do it here: http://phpfreaks.com/donations.php
-
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).
-
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.
-
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.
-
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)?
-
$_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
-
Under what conditions are users deemed as inactive?
-
<?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
-
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]
-
do you use custom made hand coded programming or framework based ?
Daniel0 replied to adilraufkhan's topic in Miscellaneous
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. -
do you use custom made hand coded programming or framework based ?
Daniel0 replied to adilraufkhan's topic in Miscellaneous
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. -
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.
-
Need to launch a "thank you" page after submitting PHP form
Daniel0 replied to NBRAD's topic in PHP Coding Help
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. -
[SOLVED] how to remove \toll free dial '1' and then\ in a string?
Daniel0 replied to homer.favenir's topic in PHP Coding Help
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); -
[SOLVED] how to remove \toll free dial '1' and then\ in a string?
Daniel0 replied to homer.favenir's topic in PHP Coding Help
If you always only need the thing before the first backslash, then you could do: strstr($string, '\\', true); -
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.
-
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.
-
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.
-
[SOLVED] how to remove \toll free dial '1' and then\ in a string?
Daniel0 replied to homer.favenir's topic in PHP Coding Help
str_replace("\\TOLL FREE DIAL '1' & THEN\\", '', $string); -
do you use custom made hand coded programming or framework based ?
Daniel0 replied to adilraufkhan's topic in Miscellaneous
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.