Jump to content

Daniel0

Staff Alumni
  • Posts

    11,885
  • Joined

  • Last visited

Everything posted by Daniel0

  1. Actually, you might want to explicitly cast the values as floats considering you are outputting those values as well. I didn't see that. So like $length = (float) $_POST['length']; etc.
  2. A value will implicitly be cast as integer or float if you perform arithmetic operations on them.
  3. Many books contain exercises for you with increasing difficulty as your skills progress. It could be something like "implement the merge sort algorithm" or "write a function that does that when given this".
  4. A rectangular cuboid has three pairs of identical faces: height*length, depth*height, depth*length. This means the surface area is given by 2hl+2dh+2dl. Put into PHP this gives you: $surfaceArea = 2*$_POST['h']*$_POST['l']+2*$_POST['d']*$_POST['h']+2*$_POST['d']*$_POST['l']; You can add parentheses if you think it makes it more readable, but its sort of redundant because because multiplication takes higher precedence than addition. It would be better if you named the sides like that. It's sort of ambiguous which side if which if you have something called "width" and "length". You normally say that you have the two dimensions "width" and "height", and then you can add the third dimension "depth".
  5. Any three-letter domain name with a popular TLD will be really expensive... People just purchase them in case it might be a useful abbreviation for somebody.
  6. Even if it was true, how would they manage to do that?
  7. One solution would be to use mod_rewrite: RewriteRule ^([a-z0-9]+)$ profile.php?username=$1 Check out the documentation for a more elaborate explanation of how it works. It's sort of the same thing we've done here: http://www.phpfreaks.com/profile/Daniel0. We just put /profile in front of the username. It's not really a directory, but the URL is rewritten to another URL that exists.
  8. No, not in your script, but the database server will most certainly take a performance hit. If you for instance encrypt the email address then you will need to store it in a BLOB, but this means you cannot make any indexes, so if you have like one million rows and need to find the user with a particular address then you'll need to check every row, which will most certainly be slower than selecting from an indexed row.
  9. What do you mean? Tabs work fine here...
  10. Size is not your only concern in software engineering. Factors such as development time, code complexity, and performance are important as well.
  11. Well, if you imagine the following string: " " (the space character repeated 10 times), then when reading it aloud, instead of saying "space, space, space, [...]" you would probably say "10 spaces" or something like that. Compression algorithms work sort of the same way in the sense that it looks for repeating pattern and figures out if there is a way to express that in a shorter way. Though gzip is obviously more sophisticated than my simple "look for consecutive identical characters" algorithm. Stripping whitespace, or replacing multiple spaces with tabs, might still have a small effect, but it's marginalized by also using a compression algorithm of some sort.
  12. Actually, given the way that compression algorithms work, if you gzip your page then this might not have any effect at the end of the day.
  13. You could do a few more optimizations: 1) Use tabs instead of spaces for indentation. That's a 4:1 ratio. Better yet, strip all the whitespace before outputting. 2) Use HTML instead of XHTML. This will allow you to do a few things like dropping a few closing tags, not using self closing tags, not needing quotation marks around certain attribute values, being able to use minimized attributes. 3) Don't know if you did this, but lots of times there are a lot of meta data in PNG files which can be stripped off. 4) The following: <dl class="DefList"> <dt class="dtimg"><a class="gui leafBullet"></a></dt> <dd>More info can be viewed over at the <a href="http://news.nationalgeographic.com/news/2004/12/1206_041206_global_warming.html">National Geographic Website</a>*</dd> </dl> <!-- repeats itself, sort of --> could be reduced to: <ul> <li>More info can be viewed over at the <a href="http://news.nationalgeographic.com/news/2004/12/1206_041206_global_warming.html">National Geographic Website</a>*</li> <!-- repeat in here instead (you could even drop the closing </li> in HTML) --> </ul> which will allow you to add rules to to #panel ul and #panel li to add the leaf instead of a standard bullet. Granted, some of it is micro-optimization, but on a large scale it would matter, and it could matter in a "smallest possible size" competition.
  14. You might want to look up on the PHP syntax using the manual first.
  15. http://en.wikipedia.org/wiki/Earth_Hour#Interpretation It's supposed to be pretty sweet if you have a space shuttle though... Kind of like a dark belt moving slowly around the earth.
  16. You have to load it using Pageant.
  17. Could be his AP that's broken or maybe he is out of range or something. Wireless not working is not necessarily a fault in the computer.
  18. You can usually write any address you want.
  19. Is it something like this you're looking for? $info = array( 'foo' => 'bar', 'msg' => 'hello', ); $url = 'http://example.com/script.php?' . http_build_query($info); // The URL will be http://example.com/script.php?foo=bar&msg=hello in this case
  20. Uh... the manual? http://php.net/function.mail
  21. It has to be of the format From: Somebody <[email protected]> or just From: [email protected]. If it already is that then your MTA is overriding it and you won't be able to fix that.
  22. $_GET['toppings'] will not be set if there are none of your toppings checkboxes that are checked. Try type casting it as an array or use a conditional control structure to avoid the loop altogether if it is empty.
  23. Yeah but it kind of has to process the data fast enough when it receives it in order to support that.
  24. How do you know they aren't already base 10? It wouldn't make sense calling it an "octet string" for other bases than 10. The words "octet" and "octal" aren't the same. "Octet" means a group of 8, while octet is the just the positional number system with the base 8. It makes sense that your 255's is in decimal. If you assume that it's the highest value then if you convert it to hex you'll have FF16, but that's only two digits. If you convert it to octal then you'll get 3778, but that's only three digits. However, if you convert it to binary then you'll get 111111112, that's eight digits, i.e. an octet of digits. You'll probably have to lookup what that string means in the docs from where it came from.
  25. Google, Yahoo, Live, etc. will hate you if you use Flash.
×
×
  • 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.