PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I've been working with LDAPS to reset a users password and password has to be in UTF-8 so
the code reads through an array byte by byte and does this.
$newPassword = "{$Password[$i]}\000";
1. What is the "\" doing? It's not a division operator. Somehow it's appending 3 zeros to the character.
2. Why the "{" brackets? This isn't a function.
The code works but I would just like to understand why.
Yes, and since you're using an array with [] sometimes it can not be interpreted as a var and it is also easier to read. \ is an esacape character. \n is a newline, \r is a return character, \000 is a null character. Dunno why they are using it there. It may have some significance in LDAP.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
Just different ways to encapsulate an array index within a string.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Thanks guys. The {} makes absolute sense. However, we finally found more about the \000. Apparently that is an escape sequence that says the string in front of it is octal. At least that is my interpretation of what I've been reading. We found that in some PERL documentation but it fits with what the PHP is doing. Now I'm going to get an extra large cup of coffee because I need it.
LarryKreeger wrote:Thanks guys. The {} makes absolute sense. However, we finally found more about the \000. Apparently that is an escape sequence that says the string in front of it is octal. At least that is my interpretation of what I've been reading. We found that in some PERL documentation but it fits with what the PHP is doing. Now I'm going to get an extra large cup of coffee because I need it.
Yes, \000 is the octal escape sequence for a null byte. \x00 would be the hexadecimal equivalent. Many times \000 would be the decimal code, \o000 would be the octal and \x000 would be the hex, but PHP only supports the \000 octal form and \x000 hex form.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
Ok obviously I haven't had enough coffee.
Sooooo you can store octals by \333 or \011 or whatever but \000 is reserved by unicode to denote the end of the character because unicode characters are variable lengths.
LarryKreeger wrote:Sooooo you can store octals by \333 or \011 or whatever but \000 is reserved by unicode to denote the end of the character because unicode characters are variable lengths.
Null character has no special significance to either Unicode or to its (most widespread) UTF-8 encoding. Sidenote: Unicode (Universal Character Set to be precise) is not encoding, it's character set, and depending on particular encoding its characters could be encoded in variable or constant (bit)lengths.