开发者

Can I implement group typing in PHP?

开发者 https://www.devze.com 2023-04-10 04:23 出处:网络
I\'m not sure whether it\'s called group typing, but what I mean is this: Since PHP is dynamically typed, this adds delays which is understandable. Is it possible to create some kind of type system i

I'm not sure whether it's called group typing, but what I mean is this:

Since PHP is dynamically typed, this adds delays which is understandable. Is it possible to create some kind of type system in PHP so that

ints,floats and other numeric values can be grouped under Number , as well as开发者_如何转开发 grouping of other types to increase runtime speeds so that if a variable is of type Number, at runtime, PHP can just quickly only check through that group without even testing if its a string or some other type.

Is this possible, or am I completely missing something here?


You're missing something. Numbers and strings aren't objects in PHP -- they're a distinct type of value, which is already handled more or less in the way that you describe.


You simply can't do that in PHP, the language doesn't have that kind of tools.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号