Jump to content

Daniel0

Staff Alumni
  • Posts

    11,885
  • Joined

  • Last visited

Everything posted by Daniel0

  1. Your production server should be configured like this already. Just make sure that your input is what you expect like: preg_match_all('#href\="([^"]+q=([^&]+)[^"]+oi=revisions_inline[^"]+)"#miu', $googleRes, $matches); return !empty($matches) && 3 <= sizeof($matches) ? array_map('urldecode', $matches[2]) : array(); The additional checks are redundant because $matches[2] will always exist and be an array even if it doesn't find anything. See: $googleRes = 'foo'; preg_match_all('#href\="([^"]+q=([^&]+)[^"]+oi=revisions_inline[^"]+)"#miu', $googleRes, $matches); var_dump($matches); Output: array(3) { [0]=> array(0) { } [1]=> array(0) { } [2]=> array(0) { } }
  2. The problem with using DOM is just that Google doesn't provide valid HTML, so DOMDocument will complain when it parses it. Also, your script doesn't output anything.
  3. Well, if Google changes its output then you just won't get any matches. You shouldn't get any error messages. Still, I tried making it as general as possible. Essentially all it does is that it looks for links that has oi=revisions_inline in it and then it extracts the q (the search query) part. If they for some reason stop doing that, then it won't work.
  4. Well, print_r just prints out an array so you can read it. You can do like this: $related = getRelatedTerms('paintball'); foreach ($related as $term) { // do something }
  5. An example of what?
  6. This should do it (until Google changes their HTML output): <?php function getRelatedTerms($term) { $url = sprintf('http://www.google.com/search?q=%s', urlencode($term)); $userAgent = 'Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.3) Gecko/20100423 Ubuntu/10.04 (lucid) Firefox/3.6.3'; $ch = curl_init($url); curl_setopt_array($ch, array( CURLOPT_RETURNTRANSFER => true, CURLOPT_USERAGENT => $userAgent, )); $googleRes = curl_exec($ch); curl_close($ch); preg_match_all('#href\="([^"]+q=([^&]+)[^"]+oi=revisions_inline[^"]+)"#miu', $googleRes, $matches); return array_map('urldecode', $matches[2]); } print_r(getRelatedTerms('paintball'));
  7. Does Kohana send a 500 status code when an application error happens? Is is possible to have your own error page, but still send a 500 response, and that would be the correct thing to do.
  8. Sticky topics in PHP Help are obviously not supposed to be asking for help. That would be pointless. Seeing as no staff member has got around to stickying this yet, I'll just do it.
  9. Deprecating the working volenteered staff structure further. Guru and PFR have never been considered staff. Read the stickies... For the record, I still have the same permissions on the forums that I had before. You can consider that a warning. Stop trolling the forums.
  10. Has anyone ever read those? Just because you have a habit of not reading rules, stickies and other important information doesn't mean nobody else do...
  11. You can integrate that with PHP Unix man pages as well to get the full documentation. pear channel-discover doc.php.net pear install doc.php.net/pman Now you should be able to access PHP documentation like pman strpos. Then it's just a matter of setting keywordprg to pman for PHP files in vim.
  12. I don't think you got my point. Take phpfreaks.com for instance. With all the custom installations and configurations, there is no way shared hosting would work for us even if they provided us with enough resources (disk space, bandwidth, memory, CPU time, etc.). There is just not enough flexibility for our needs. This is completely regardless of resource usage and others might very well have the need for this kind of flexibility without having high resource needs. Setting up an SVN repo was just an example.
  13. Man... I've always wanted to know what the last digit of pi is. Can you post it here? Besides, I wouldn't call calculating a lot of pi's digits or generating reverse lookup and rainbow tables for "normal usage". What makes you say that? What if you want to run custom services like your own SVN repository? What if you just don't want other people on your system for security/stability reasons? What if you just want to manage your own software or don't want to have to go through the hoops of various control panels to do something you can do efficiently from the shell? The minimal required RAM for a desktopless Debian install is 64 MB RAM. The recommended minimum is 256 MB. If you don't install some bloated cPanel or whatever (or even worse, a desktop environment), you'll do just fine starting out with 256 MB. To be honest, I don't see the point in paying for more when you can upgrade at any time you want.
  14. You must be every salesman's dream. Easy to oversell. I bet you would do just fine with 256 MB. The benefit of a VPS is that you can change how much memory you're allowed to allocate while it's running, so it's just a matter of contacting the sales department asking for an upgrade. Why would you pay for something you don't need? Especially seeing as you've got a £20/mo max. Reaching that will be much easier if you scale down your requirements to something realistic. There is no way you'll need 1 GB (or even 2 GB) memory if you don't even have any traffic yet. Also, "unmetered bandwidth"? That's not going to happen. At least not within your price range.
  15. Are you sure you need 1 GB memory? This server uses about 1 GB of memory right now. It has a semi-large database, an active forum, an IRC server and corresponding IRC services as well as a daemon for a live chat client. What kind of traffic do you have?
  16. The Java Runtime VM doesn't compile the code when you execute .class files. At that point it has already been compiled.
  17. Maybe your computer is just slow?
  18. Have a look at this: http://vim.wikia.com/
  19. There is a GUI version for it. It's called GVim.
  20. There is also a vim plugin for Eclipse.
  21. Mine would be Zend Studio, NetBeans and vim (in no particular order).
  22. This is a continuation of this topic: http://www.phpfreaks.com/forums/index.php/topic,54859.0.html
  23. If you want advanced stuff, you have to move away from PHP book and buy books that deal with general programming stuff. Programming is not just "programming" though. There are many different things you might want to focus on. You could read about algorithms and make your stuff run fast. You could read about things like semantics and lambda calculus to get a better idea of what exactly a programming language is. Maybe things like computability would be interesting, i.e. what is it possible to compute, and can it be done within reasonable time (has a lot to do with algorithms as well). Maybe you would find concurrency and making things run in parallel interesting. Or you might be interested in how to make well designed applications, or how to manage programming projects. There are so many things to programming that it's difficult suggesting an "advanced" book. I might suggest Introduction to Algorithms, but if algorithms aren't really your thing, you might find The Pragmatic Programmer more interesting. Both books can be said to be related to programming, but they are very different books.
  24. We would encourage everybody to introduce themselves here so we might get to know you and "old" members are very welcome to introduce themselves as well.
×
×
  • 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.