php vm 에서 zval 이라는 구조체에 담겨
https://www.phpinternalsbook.com/php5/zvals/basic_structure.html
PHP internals book
이거를 한 3년전에도 보고 2년전에도 봤는데
Among other things, every zval stores some value and the type this value has. This is necessary because PHP is a dynamically typed language and as such variable types are only known at run-time and not at compile-time. Furthermore the type can change during the life of a zval, so if the zval previously stored an integer it may contain a string at a later point in time.
The type is stored as an integer tag (an unsigned char). It can be one of eight values, which correspond to the eight types available in PHP. These values are referred to using constants of the form IS_TYPE. E.g. IS_NULL corresponds to the null type and IS_STRING corresponds to the string type.
The actual value is stored in a union, which is defined as follows:
무엇보다도 모든 zval은 일부 값과 이 값의 유형을 저장합니다. 이는 PHP가 동적으로 타입이 지정된 언어이기 때문에
동적으로 타입이 지정된 언어이므로 변수 타입은 컴파일 타임이 아닌 런타임에만 알 수 있습니다. 또한
zval의 수명 동안 유형이 변경될 수 있으므로 이전에 정수를 저장한 경우 나중에 문자열을 포함할 수 있습니다.
문자열을 포함할 수 있습니다.
유형은 정수 태그(부호 없는 문자)로 저장됩니다. 8개의 값 중 하나가 될 수 있으며, 이는 PHP에서 사용할 수 있는 8개의
유형에 해당하는 8개의 값 중 하나일 수 있습니다. 이러한 값은 IS_TYPE 형식의 상수를 사용하여 참조됩니다. 예: IS_NULL
은 널 유형에 해당하고 IS_STRING은 문자열 유형에 해당합니다.
실제 값은 다음과 같이 정의되는 유니온에 저장됩니다.
타입캐스팅을 하면 타입이 바뀜
이렇게 되어있어
뭐 코딩하는데는 아무짝에 쓸모없구 php vm 코드 보고 기여할사람들 보라고 만들어놓은거
댓글 0