Jump to content

Daniel0

Staff Alumni
  • Posts

    11,885
  • Joined

  • Last visited

Everything posted by Daniel0

  1. http://en.wikipedia.org/wiki/Decorator_pattern
  2. If you had used a proper indentation style you would have seen the parse error immediately. There is a reason why such styles exists. http://en.wikipedia.org/wiki/Indent_style The most popular of those are K&R and Allman. There is also the ZF style.
  3. Though one might see it as somewhat pedantic, I would not recommend using the SMF source code as the base of learning for a beginner. Generally, I would be very cautious using other people's code for learning purposes unless you have a lot of experience with programming. One of the downsides with PHP is that it's easy to write something in it, meaning it's also easy to write something that sucks (but still technically "works"). One of the things you absolutely must do is to read through Language Reference, Security and Features in the manual. These chapters take introduce important concept and constructs in PHP that you must know how to use. PHP's manual is really good, so don't be afraid to check it often. You can probably skip the OOP section for now though; OOP is much more than just syntax. Nobody can really tell you how to create a "forum". It can be anything from a pretty simple script, to a very complex one. After you've read the 3 chapters I just mentioned, you'll have to sit down and identify the various components your forum will be comprised of. As an example, you would likely want users to be able to register and log in. That is one "component". You can further break registering a user down: 1) Display form, 2) Read and validate input, 3) Insert user into database. One of the key skills of any programmer is being able to break a large and complex problem into smaller problems. When you've solved one of the smaller and easier sub-problems, you have partially solved the complex main problem. We have a number of tutorials that introduce important concepts in respect to programming in PHP. After you've read the aforementioned PHP manual chapters, you might want to read the following tutorials: http://www.phpfreaks.com/tutorial/php-loops http://www.phpfreaks.com/tutorial/php-security http://www.phpfreaks.com/tutorial/php-basic-database-handling http://www.phpfreaks.com/tutorial/sessions-and-cookies-adding-state-to-a-stateless-protocol Also check out this blog post so you won't end up using a horrible practice that unfortunately is commonplace amongst many PHP programmers. Good luck with your programming endeavors! One thing you must keep in mind is that programming is not easy. Writing code may be easy, but writing good code is difficult.
  4. Uh... just set your form's action to https://secure175.sgcpanel.com:2096/login/
  5. Fixed.
  6. Note that the microtime(true) - $start in your if statement and the one you are echoing are not the same. Time will have passed between these two. If you want it to be the same you'll have to assign it to a variable and use that instead.
  7. $start = microtime(true); usleep(500000); if (microtime(true) - $start >= 0.5) { echo 'Half a second has passed.'; }
  8. That doesn't make sense. Why wouldn't it be accurate? Or rather, why would it be too inaccurate?
  9. You can also check the MIME type on server side: http://php.net/fileinfo
  10. Ignoring the fact that you're accessing array indices incorrectly, it works fine for me. You'll have to elaborate on "doesn't work".
  11. I'm not sure I understand you. In PHP, (float) 20 === 20.0.
  12. Cast it as int or use any of round, ceil or floor depending on your needs. The difference between casting to int (truncating) and flooring is that flooring rounds towards negative infinity and truncating rounds towards 0.
  13. Same concept. <?php $number = 525; $parts = array(); $div = pow(10, strlen($number) - 1); $n = $number; while ($div >= 1) { $parts[$div] = (int) ($n / $div) * $div; $n = $n % $div; $div /= 10; } print_r($parts); I just want to point out that it is mathematically incorrect to say that there are 500 hundreds in the number 525 though. 525 = 5*102 + 2*101 + 5*100
  14. $hundreds = (int) $number / 100; That'll give you how many hundreds there are.
  15. Just divide by multiples of 10.
  16. http://php.net/pdo
  17. So does PHP's standard library. That's somewhat of a pipe dream. Migrating to another database system is unlikely to be the trivial task you make it sound like. That is unless you restrict yourself to the very basic UPDATE/DELETE/INSERT statements of course.
  18. I can help you write the script, but not write it for you (not for free anyway). Do an attempt first yourself.
  19. In the same way. Each part has its own header section. Identify the boundary, the split the entire message up. You'll then find the body of each part the same way as before.
  20. http://lmgtfy.com/?q=mime+multipart+message
  21. Right, okay. That's because it's a MIME multipart message. Look it up.
  22. You could do something like this (not tested): <?php $lines = file('the_email'); for ($pos = 0; !empty(trim($lines[$pos])); ++$pos) {} $body = join('', array_slice($lines, $pos));
  23. The text is always after the first blank line. Otherwise it's not an email, but something else. Which particular order the headers are in is irrelevant, but the headers are always at the top (obviously) and then the body follows.
  24. Those lines are known as headers. The headers will always end after the first blank line, so that is where the email body will begin.
  25. What are you actually trying to do?
×
×
  • 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.