I have basic PHP question
lets say I have a string "02/03/2013", how is this represented internally in PHP, is it converted to integers or to a Hexadecimal equivalent
when comparing two strings, how does PHP compare them internally?
Thanks for the answer in advance
PHP is written in C. All variables are ZVAL structs.
Please read these tutorials to learn more about the PHP internals and get started with writing extensions.
Table 1 shows the various types, and their corresponding letter codes and C types which can be used with zend_parse_parameters():
Type Code Variable Type
Boolean b zend_bool
Long l long
Double d double
String s char*, int
Resource r zval*
Array a zval*
Object o zval*
zval z zval*
A PHP string is just a sequence of bytes, with no encoding tagged to it. Visit here for additional info..
Strings are strings. No conversion takes place; your string just happens to contain some digits, which is fine, but PHP doesn't treat it any differently than any other string.
PHP compares strings the same way that any other language would: it goes through the two strings character by character, and looks for the first pair of characters that differ. Once it finds one, the string which had a character with a lower ASCII value (like you'd get from ord()
) is considered as being "less" than the other string.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.