Are there dictionaries in php?
http://php.net/manual/en/language.types.array.php Standard arrays can be used that way.
http://php.net/manual/en/language.types.array.php Standard arrays can be used that way.
No need to use string functions. You can use something that’s actually designed for what you want: pathinfo():
After this question was asked, Facebook launched HipHop for PHP which is probably the best-tested PHP compiler to date (seeing as it ran one of the world’s 10 biggest websites). However, Facebook discontinued it in favour of HHVM, which is a virtual machine, not a compiler. Beyond that, googling PHP compiler turns up a number of 3rd party solutions. … Read more
Ok so PHP has the function ini_set() which a lot of people are aware of and will use to set various configuration options (here) to help with development etc. However, this function does only seem to work at runtime and will not work if there are any fatal errors or the script has syntax errors and can’t … Read more
What about this one simple command which not just finds but clears the nasty BOM? 🙂 I love “find” 🙂 Warning The above will modify binary files which contain those three characters. If you want just to show BOM files, use this one:
Using password_hash is the recommended way to store passwords. Don’t separate them to DB and files. Let’s say we have the following input: You first hash the password by doing this: Then see the output: As you can see it’s hashed. (I assume you did those steps). Now you store this hashed password in your database, ensuring your … Read more
Only double quoted strings interpret the escape sequences \r and \n as ‘0x0D’ and ‘0x0A’ respectively, so you want: Single quoted strings, on the other hand, only know the escape sequences \\ and \’. So unless you concatenate the single quoted string with a line break generated elsewhere (e. g., using double quoted string “\r\n” or using chr function chr(0x0D).chr(0x0A)), the only other way to have a line break … Read more
You can use either date or strftime. In this case I’d say it doesn’t matter as a year is a year, no matter what (unless there’s a locale that formats the year differently?) For example: On a side note, when formatting dates in PHP it matters when you want to format your date in a different locale than … Read more
32767 + 1 is a power of 2 Binary representation of numbers uses powers of 2. So, in an 4-bit structure, 0101 is 2^0 x 1, 2^1 x 0, 2^2 x 1, and 2^3 x 0 which is 5. The MSB is used for sign and unsigned integers.
One permission requirement that is often overlooked is a user needs x permissions in every parent directory of a file to access that file. Check the permissions on /, /home, /home/demo, etc. for www-data x access. My guess is that /home is probably 770 and www-data can’t chdir through it to get to any subdir. … Read more