Jump to content

Daniel0

Staff Alumni
  • Posts

    11,885
  • Joined

  • Last visited

Everything posted by Daniel0

  1. I do this: <?php function __autoload($class_name) { require str_replace('_', DIRECTORY_SEPARATOR, $class_name) . '.php'; } ?>
  2. I don't know if it's based on post count or if it's because I'm in the "PHPFreaks Recommended" group, but currently there are 27 PMs in my inbox. Does it give you any error?
  3. What do you mean?
  4. No. You might be able to do things faster and therefore more efficiently, but you do not have any sort of power. Which CLI are you referring to? I suppose you mean Linux. You cannot open a file using the CLI, but you can run a program which will open the file. E.g. $ vim some_file.txt $ nano some_file.txt To delete a file/folder you'll use rm. This takes various flags which you can see by running $ man rm (you can most likely see a manual page for something by typing man <whatever>, e.g. man ls, man mkdir etc.) There are various things you should take care of to not wreck your computer. E.g. don't be root when you don't need to, watch out when using the -r (recursive) and -f (force) flags with rm. You can take a look at this. I haven't read it, but it was the first result for "bash scripting" on Google.
  5. Huh? roopurt's post is one long explanation.
  6. Ah, used the wrong operator :-\ Second post was based on first so I didn't catch it there either. So roopurt, yes, I did introduce a bug
  7. I was thinking he wanted to move very_expensive_operation() somewhere so it would only be run if needed and not always. I figured that was why he named the function as he did.
  8. No, I can't prove that I didn't make any bugs. I actually thought about that and it kind of bugs me that I couldn't. I suppose that is partially because I don't know what the function is indented to do and what it's intended output is and partially because very_expensive_function() is not defined in the above snippet. Also, $asdf is not used so it's just redundant but I don't see any way of removing it from the argument list without breaking code that is dependent on the function.
  9. :\ <?php function doThis($foo, $bar, $asdf, $x, $y, $z, $m, $n, $o) { if(empty($m)) { return 1 / $bar; } else if(($n == 'one' && ($x < $y && $x > $z)) || ($o == 'two' && (($x < $y && $x < $z && ($y + $z <= 10)) || !($x >= $y || $x >= $z || ($y + $z <= 10))))) // <-- wtf? { return ($y * $z + $x) * $bar; } else if($n == 'one' || $o == 'two') { return ($bar + very_expensive_operation($m, $n, $o)) / $foo; } else if($n == 'one' && ($x >= $y || $x <= $z)) { return ($y / $z - $x) * $bar; } else { return $foo / $bar; } } ?>
  10. Like this? <?php function doThis($foo, $bar, $asdf, $x, $y, $z, $m, $n, $o) { if(empty($m)) { return 1 / $bar; } else if($n == 'one') { if($x < $y && $x > $z) { return ($y * $z + $x) * $bar; } else if($x >= $y || $x <= $z) { return ($y / $z - $x) * $bar; } else { return ($bar + very_expensive_operation($m, $n, $o)) * $foo; } } else if($o == 'two') { if($x < $y && $x < $z && ($y + $z <= 10) || !($x >= $y || $x >= $z || ($y + $z <= 10))) { return ($y * $z + $x) * $bar; } else { return ($bar + very_expensive_operation($m, $n, $o)) / $foo; } } else { return $foo / $bar; } } ?>
  11. For AJAX you really just need to learn Javascript. You could take a look at http://developer.mozilla.org/en/docs/AJAX though. I would recommend you to use Javascript frameworks such as Prototype or jQuery (my favorite).
  12. I'd love to hear some of those exercises.
  13. Send these headers: Expires: 0 Cache-Control: must-revalidate, post-check=0, pre-check=0 Pragma: no-cache You can use the header() function for that. Use one header per function call and do it before you output anything.
  14. You can make a quiz in any language you would like.
  15. Python is an excellent language you might want to learn as well.
  16. Eh? Do tell. http://www.phpfreaks.com/forums/index.php/topic,175791.msg779491.html#msg779491
  17. Searching wouldn't do that either... There would be multiple pages as well (depending on the rows returned of course).
  18. The sound is really poor.
  19. Those translation tools cannot always interpret what's written correctly. Dibujo is for instance both 1st person singular (I draw) of the verb dibujar, but it can also mean a drawing (dibujo un dibujo = I draw a drawing). There are also several English words which have different meanings depending on the context which they appear in. You're better off finding somebody who speaks Spanish fluently. There are several translation companies, try to do a search on Google.
  20. The fourth version of KDE, which is a desktop environment. It would probably have been faster to searched for it on Google than posting and waiting for a reply.
  21. <?php $long = ip2long($ip); if($long == -1 || $long === false || long2ip($long) != $ip) { echo 'The IP is invalid'; } ?> Based of examples from: http://php.net/ip2long
  22. Well, that's like writing regular text on paper. Imagine you have 50 paragraphs and after you wrote them you find that you would like to add another paragraph between number four and five.
  23. If you have PHP 5 (which you should!) then you can also use the hash() function which supports more algorithms like sha256, sha512, ripemd256, etc. edit: fixed link
  24. I believe it's dedicated hosting where the company you lease the server from manages the server.
  25. Code blocks are chunks of code contained within curly braces ( { } ). Example: if(something) { // here is a code block } while(something_else) { // another code block } The code inside the first code block is executed if something evaluates to true. The code within the second code block is executed as long as something_else evaluates to true. If the value never changes you'll have an infinite loop, i.e. the script will eventually time out and result in an error. Does the exact code I provided work or do you have problems with that?
×
×
  • 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.