Jump to content


Staff Alumni
  • Posts

  • Joined

  • Last visited


Everything posted by Koobi

  1. no problem. mrMarcus was just joining your results together and using a pipe '|' to distinguish between the two pieces of data. he has a point, that method has its uses too but in my humble opinion, i thought the array method might work out better in your situation.
  2. j0n, if i'm not mistaken, i think he meant that he wanted to populate the $definedPages array based on the HTML anchor tags in a page. not the other way around. there are always ways to do things like that via regular expressions and whatnot but that's really bad practice. ideally, you could have an include at the top of the page that defines this array. but grabbing the links in a page by parsing the HTML would be a very bad idea though it can be done. anyway, if you have more questions on this, you should probably make a new thread unless the OP doesn't mind this in his thread
  3. Yeah, but nobody writes code like that anyway. It's an example that wouldn't appear in real applications. You might for instance make sort of integrity check, or you might later want to abstract it away using a strategy or you might want to use a proxy. You cannot do that if you're directly accessing your properties. i was thinking about that too...what if you decide to do some kind of processing before you set or get a method. i think getters and setters are good practice based on the situation. for example, if you're setting values to insert into a database, i think it's alright to set the values to the property directly because and processing that has to be done to a variable before entering it into the database should be dealt with in the model (if you're using the MVC pattern). that's probably the only instance where i'm on the fence about getters and setters. google is weird sometimes...their creativity level is awesome but the way they code some web apps just don't make sense. maybe i'm missing something because most of them are probably pretty damn smart.
  4. haha i've been working with PHP since the early 4.x releases and i still make stupid mistakes that make me feel like a total idiot once little thing about your switch case...always have a 'default' catch all. because, what if i decide to type the URL in manually and i do: http://site.co.uk/index.php?page=imanidiotsometimes if you really want to make your navigation cleaner, you can do this: $definedPages = array('default', 'print', 'web'); $myPath = 'path/to/dir/'; if (in_array($_GET['page'], $definedPages)) { require_once $path . 'img' . $_GET['page'] . '.php'; } else { require_once $path . 'imgdefault.php'; } the url's would look like: http://site.co.uk/index.php?page=web http://site.co.uk/index.php?page=print http://site.co.uk/index.php?page=default http://site.co.uk/index.php?page= http://site.co.uk/index.php the last three url's would give you the same result. the only disadvantage here is that the switch/case is fractionally faster than an if condition but for a simple navigation, this wont be an issue. i'm talking about microseconds. why do i hide the 'img' part from the end user? just because it's better that the end user has no idea whats going on in your backend for security reasons.
  5. ^^ i believe what mrMarcus said about embedding HTML is true. regarding concatenating your data with a string, however, if FORUM_TOPIC happens to contain a pipe '|', you will get unexpected results. so, if you want, you could stick your results into an array and iterate through them like this: your method modified: public function forumTopics() { $sql = "SELECT * FROM forum_topic WHERE forum_topic.user_id='".$this->userId."' ORDER BY datetime DESC LIMIT 5"; $result=$this->db->query($sql); while ($row = $result->fetch()) { $FTopics[] = array($row[FORUM_TOPIC], $row[FORUM_ID]); } return $FTopics; } now, the return value will be an array of arrays. if you need to visualize this to proceed, do this: print_r($user->forumTopics()); or var_dump($user->forumTopics()); feel free to warp that output with HTML <pre> tags if it makes it more pleasant to look at. now, you can access your data like this: foreach($user->forumTopics() as $index => $record) { echo "Record number: $index<br />"; echo 'Topic: ' . $record[0]; echo 'ID: ' . $record[1]; }
  6. I would rather do it like this: function forumTopics() { $sql = "SELECT * FROM forum_topic WHERE forum_topic.user_id='".$this->userId."' ORDER BY datetime DESC LIMIT 5"; $result=$this->db->query($sql); $FTopics = array(); //initialize as an array while ($row = $result->fetch()){ //it makes no sense to use $this here $FTopics[] = $row[FORUM_TOPIC] .'<br />'; } return $FTopics; } this is my reasoning: * initializing PHP is a scripting language and like most scripting languages, it is loose typed, in that, you don't need to tell PHP a variable can only store integer or string. a variable in PHP can store any of the types. but, it is good practice to initialize variables according to their types. at the end of the day, it's about personal preference and how clean you want your code. so since $FTopics will be storing data as an array, i chose to initialize it as an array. this also makes the code easy to read...for some reason if i have to initialize it further up in my code, the fact that i initialized it as an array will give me a hint as to what that variable will later contain. * not using $this i wouldn't use $this->FTopics unless i need to use this data elsewhere in the class. if you need the forum topics to be returned to you and discarded, just use a regular variable. when you use $this, you are involving the whole class as your scope. if you have not designed or planned this carefully, you might have another variable called $this->FTopics which can overwrite or append the one within your forumTopics() method. therefore, use $this sparingly and only if you need it or things can get buggy. also, if you do end up using $this, you should be initializing it outside the methods like: MyClass { private $FTopics = array() public function forumTopics() { $sql = "SELECT * FROM forum_topic WHERE forum_topic.user_id='".$this->userId."' ORDER BY datetime DESC LIMIT 5"; $result=$this->db->query($sql); while ($row = $result->fetch()) { $this->FTopics[] = $row[FORUM_TOPIC] .'<br />'; } return $this->FTopics; } }
  7. vim is my choice file management? do you mean something like Vim Project? vim has PHP function recognition, you just have to get the file from the vim site. regex search/replace has always existed in vim too. ftp is also supported. although i prefer scp via ssh every unix/linux machine out there will have vim or vi (older version) on it so if you do get used to vim, doing an urgent remote edit won't be a problem. there's tons more that vim can do. i'll admit it's not the most pleasant editor to get used to but once you do start using it, your productivity will shoot skywards because it's so efficient.
  8. Koobi

    I'm back

    haha yeah, i could never forget gizmola's avatar. i believe it was the picture of a baby with a sour expression on his face and the words "RTFM" in bright yellow right over his head.
  9. wow i just looked at the results and i'm surprised so many people here use DreamWeaver. i haven't strayed from vim. i've tried many other editors but vim is still so flexible. it can do anything i want it to.
  10. Koobi


    salatha, i've seen you on some other forum...i just can't remember which. sitepoint? theroot42? in any case, welcome.
  11. Koobi

    I'm back

    haha i think i left about 2 years ago. i was just browsing the forum the other day and it's almost impossible to find a thread without any answers in it. good going guys!
  12. i'm back at the forums after a while too. i THINK i remember you from back in the day. i didn't read your entire post but welcome back
  13. that's excellent news about the kid! Congrats.
  14. Koobi

    I'm back

    Good to hear some of you remember me. It's nice to be back I kinda missed PHP but I'm making up for it by working on it for 18+ hours a day for fun!
  15. Koobi

    I'm back

    Hi, I used to frequent PHPFreaks a lot back in the day but life took a crazy turn and I had no time to do the things I loved to. This basically means I had no time to code in PHP and sleep But I'm back. Started seriously coding again. I've seriously gone into Linux administration although I haven't worked in that position for a few months. I learnt some Ruby and then Rails because I really liked their philosophy. I revisited PHP and liked the direction it was taking with 5.2 onwards so here I am. - Housni
  16. this would tell you exactly what OS your use # cat /etc/issue also, the output of this might be useful: # uname -a i suppose you could check your processes to see if anything is taking up a lot of memory or if your server load is too high by typing: # top and maybe view your apache logs/system logs? also, is your system memory usage alright? # cat /proc/meminfo should show you those details. effigy might have a better solution for you though.
  17. yeah i'd like people to use PHP5 too as I've mentioned but there are real life situations where using the older versions are required. iv've come accross such situations at work but thank god we use redhat for our servers.
  18. when i was working with Photoshop (version 5.0 through to early CS) the Photoshop Bible was brilliant! i read the book cover to cover (this was the bible for 7.0) and it really got me very familiar with the tools...but you should definitely try the practical tutorials online to know what to use which tool when.
  19. well, i just think that if they are going to call Ubuntu the user friendly Linux for the beginner, they should make things very easy. if it was gentoo or something like that, i'd understand them discontinuing PHP4 since gentoo users will most likely know how to compile a program...and if they don't the only thing the gentoo wiki doesn't cover is how to build a space rocket. but yeah, i think ubuntu should make things easy for the user since that is what they represent...btw, does anyone know if debian repos's support PHP4?
  20. well my app is targetted for online use across multiple users. you didn't mention what you intended to use it for so i assumed it was the same as mine but i would find an RSS feed useful if many users are using this app so that they know what files exist on the server. regarding streaming...your best and easiest bet would be Flash or intense JS...this guy who works at Yahoo,,,Scott Schiller made an mp3 streaming...thing, not sure where it was but google for him and you should find something.
  21. but there are situations where you would need an older version for either a dependency issue (where you can only use an older version of a dependecy library which the newer versions don't support) and if you are put in that situation, you are going to be in a big mess. PHP.net allows you to download the older versions as well so I believe Ubuntu repositories should. we should be given the choice. we know what is best suited for our system.
  22. yep, no more PHP4 support. you can always add your own repositories to support PHP4 but the default Ubuntu repositories don't support it. I think people should switch to PHP5 but I don't think they should leave people with no option but to use PHP5. People should have a choice of software. what do you mean? what have they done? I haven't upgraded yet but I'm considering it.
  23. i'm actually doing the same thing. but the mp3 side of things is a small component of the entire app. i also allow the users to upload a compressed file (.zip, .tar.gz, etc) and i decompress them and tag them via MusicBrainz's XMLWebService (http://wiki.musicbrainz.org/XMLWebService). The files when displayed are sortable according to their file system metadata (size, date accessed, etc) as well as the ID3 tags. apart from saving to the db for searching, i also produce an RSS feed of what files exist. when listing the files, i have a checkbox next to each file and if you check a bunch of files and submit the form, it will prompt you to download a compressed file (with a format of your choice) that contains all the files you selected.
  24. According to the Zend staff, Zend Optimizer won't work with IonCube but you can make them work so long as you first load IonCube and then load Zend Optimizer. If you are using Zend Core to configure you PHP settings, don't do so. Their latest version has a lot of bugs which they will fix and release in a few weeks.
  25. oh ok, well since you are running it via exec(), PHP can't do anything about the settings. in any case, i'm not sure about the settings either. i think you probably have to set those settings when you configure the 7zip library before you compile to install it. sorry i can't help, i'm not familiar with 7zip. maybe you can look it up on their site?
  • 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.