Jump to content

Daniel0

Staff Alumni
  • Posts

    11,885
  • Joined

  • Last visited

Everything posted by Daniel0

  1. If you read the page I linked to you would find out that variable interpolation only works with double quoted strings. You would also find out what variable interpolation is.
  2. I'm sure MD5 appreciates you're trying to protect it from SQL injections...
  3. http://php.net/manual/en/language.types.string.php
  4. A form is not vulnerable to CSRF if it requires a password like yours does.
  5. You will have to do $_POST['bcc'] instead.
  6. You might try to set CURLOPT_SSL_VERIFYPEER to false.
  7. Yes. http://www.phpfreaks.com/forums/index.php/topic,259674.0.html
  8. The second will need more memory. If you need to pass an entire result set to something else you can lazy load it for improved performance. I once wrote an example of that. Try to search the forums for it.
  9. ctype_alnum() checks if a string solely consists of alphanumeric characters. That is the alphabetic characters a-z and A-Z and the numeric characters 0-9. It's essentially the same as the regex I posted.
  10. Well, if you ever work on a project with a lot of code you will appreciate that entities are loosely coupled and that the responsibility of these entities is not all-encompassing. Things should have as little responsibility as they need so it's function becomes easier to describe. This makes testing it a lot easier.
  11. If it starts with and ends with either an alphanumeric character, and the string is only allowed to be comprised of alphanumeric characters, isn't that just ^[a-zA-Z0-9]+$ (or ctype_alnum)? Or am I missing something?
  12. Then try this: if (preg_match('#^(?:0|-?[1-9]\d*)$#', $val)) { }
  13. 9three, no, I still don't buy it. I can keep adding on "say I later optionally want X" ad infinitum and end up with hundreds of arguments in the procedural analogue to OOP's "God Object". See this topic for some of my past comments regarding this.
  14. It would be the same thing, just with different arguments: $_POST = array_map('mysql_real_escape_string', $_POST); I wouldn't advise you to do that though. It would be better just filtering the values you need instead of writing code that has side effects in the global space.
  15. If you insist... straight from the manual: <?php function cube($n) { return($n * $n * $n); } $a = array(1, 2, 3, 4, 5); $b = array_map("cube", $a); print_r($b); ?> Output: Array ( [0] => 1 [1] => 8 [2] => 27 [3] => 64 [4] => 125 )
  16. Ok, Sure how do i use array_map() that's a new one to me iv never used it ?, James. Why don't you follow the link to the manual page? I don't buy it. Then you might as well create wrapper functions around all the library functions provided by PHP in case you might want to customize it later on.
  17. It's a pointless function though.
  18. Well, it's a correct function (there is no such thing as an "incorrect function"), but you can't use it the way you want to. If you want to apply a string operation on an array you'll have to use array_map or iterate over all the elements in the array to apply the string operation on each element manually.
  19. That depends on what you are going to use it for. You could potentially implement some interesting things with an address class such as geolocation and perhaps calculation of the distance between two addresses (like $address->getDistance($otherAddress)). Saying that a particular usage example is overkill in a hypothetical example often doesn't make much sense.
  20. That you cannot instantiate an object of that class. It might not make sense in the system to just have a property because you operate with either residential or commercial properties. In this case, commercial properties and residential properties would be concrete implementations of the general idea "a property".
  21. Then why does PHP have magic methods?!
  22. Not true. It can also be abstract if it's just not supposed to be instantiated.
  23. It would work if you've configured PHP to implicitly start output buffering when execution starts. See the output_buffering directive in php.ini.
×
×
  • 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.