Перейти к содержанию

PHP Шпаргалки: различия между версиями

48 байт добавлено ,  00:20, 3 ноября 2022
(→‎Приведение типов: Оптимизация)
Строка 118: Строка 118:
| "NULL"
| "NULL"


| bool(false)
| false


| int(0)
| int(0)
Строка 124: Строка 124:
| float(0)
| float(0)


| string(0) ""
| <code>""</code>


| []
| [ ]
| {}*
| { }**
|-
|-
! true
! true
| "boolean"
| "boolean"


| bool(true)
| true


| int(1)
| int(1)
Строка 138: Строка 138:
| float(1)
| float(1)


| string(1) "1"
| "1"


| [true]
| [true]
| {"scalar":true}*
| {"scalar":true}**
|-
|-
! false
! false
| "boolean"
| "boolean"


| bool(false)
| false


| int(0)
| int(0)
Строка 152: Строка 152:
| float(0)
| float(0)


| string(0) ""
| <code>""</code>


| [false]
| [false]
| {"scalar":false}*
| {"scalar":false}**
|-
|-
! 0
! 0
| "integer"
| "integer"


| bool(false)
| false


| int(0)
| int(0)
Строка 166: Строка 166:
| float(0)
| float(0)


| string(1) "0"
| "0"


| [0]
| [0]
| {"scalar":0}*
| {"scalar":0}**
|-
|-
! 1
! 1
| "integer"
| "integer"


| bool(true)
| true


| int(1)
| int(1)
Строка 180: Строка 180:
| float(1)
| float(1)


| string(1) "1"
| "1"


| [1]
| [1]
| {"scalar":1}*
| {"scalar":1}**
|-
|-
! 1.0
! 1.0
| "double"
| "double"


| bool(true)
| true


| int(1)
| int(1)
Строка 194: Строка 194:
| float(1)
| float(1)


| string(1) "1"
| "1"


| [1]
| [1]
| {"scalar":1}*
| {"scalar":1}**
|-
|-
! M_PI
! M_PI
| "double"
| "double"


| bool(true)
| true


| int(3)
| int(3)


| float(3.14159...)
| float(3.1...)


| "3.14159..."
| "3.14159..."


| [3.14159...]
| [3.14159...]
| {"scalar":3.14159...}*
| {"scalar":3.141...}**
|-
|-
! INF
! INF
| "double"
| "double"


| bool(true)
| true


| int(0)
| int(0)
Строка 222: Строка 222:
| float(INF)
| float(INF)


| string(3) "INF"
| '''"INF"'''


| [INF]
| [INF]


| {"scalar":INF}*
| {"scalar":INF}**


|-
|-
Строка 232: Строка 232:
| "double"
| "double"


| bool(true)
| '''true'''


| int(0)
| '''int(0)'''


| float(NAN)
| float(NAN)


| string(3) "NAN"
| '''"NAN"'''


| [NAN]
| [NAN]


| {"scalar":NAN}*
| {"scalar":NAN}**


|-
|-
Строка 248: Строка 248:
| "string"
| "string"


| bool(false)
| false


| int(0)
| int(0)
Строка 254: Строка 254:
| float(0)
| float(0)


| string(0) ""
| <code>""</code>


| [""]
| [<code>""</code>]
| {"scalar":""}*
| {"scalar":<code>""</code>}**
|-
|-
! "0"
! "0"
| "string"
| "string"


| bool(false)
| '''false'''


| int(0)
| int(0)
Строка 268: Строка 268:
| float(0)
| float(0)


| string(1) "0"
| "0"


| ["0"]
| ["0"]
| {"scalar":"0"}*
| {"scalar":"0"}**
|-
|-
! "1"
! "1"
| "string"
| "string"


| bool(true)
| true


| int(1)
| int(1)
Строка 282: Строка 282:
| float(1)
| float(1)


| string(1) "1"
| "1"


| ["1"]
| ["1"]
| {"scalar":"1"}*
| {"scalar":"1"}**
|-
|-
! "true"
! "true"
| "string"
| "string"


| bool(true)
| true


| int(0)
| '''int(0)'''


| float(0)
| float(0)


| string(4) "true"
| "true"


| ["true"]
| ["true"]
| {"scalar":"true"}*
| {"scalar":"true"}**
|-
|-
! "false"
! "false"
| "string"
| "string"


| bool(true)
| '''true'''


| int(0)
| int(0)
Строка 310: Строка 310:
| float(0)
| float(0)


| string(5) "false"
| "false"


| ["false"]
| ["false"]
| {"scalar":"false"}*
| {"scalar":"false"}**
|-
! "null"
| "string"
 
| bool(true)
 
| int(0)
 
| float(0)
 
| string(4) "null"
 
| ["null"]
| {"scalar":"null"}*
|-
|-
! []
! []
| "array"
| "array"


| bool(false)
| '''false'''


| int(0)
| '''int(0)'''


| float(0)
| float(0)


| style="background-color: #ffff66"| "Array"
| style="background-color: #ffff66" | '''"Array" *'''
| []
| [ ]
| {}*
| { }**
|-
|-
! [0]
! [0]
| "array"
| "array"


| bool(true)
| true


| int(1)
| int(1)
Строка 351: Строка 337:
| float(1)
| float(1)


| style="background-color: #ffff66"| "Array"
| style="background-color: #ffff66" | '''"Array" *'''
| [0]
| [0]
| {"0":0}*
| '''{"0":0}**'''
|-
|-
! ["abc"]
! ["abc"]
| "array"
| "array"


| bool(true)
| true


| int(1)
| int(1)
Строка 364: Строка 350:
| float(1)
| float(1)


| style="background-color: #ffff66"| "Array"
| style="background-color: #ffff66" | '''"Array" *'''
| ["abc"]
| ["abc"]
| {"0":"abc"}*
| '''{"0":"abc"}**'''
|-
|-
! ["a"=>"b"]
! ["a"=>"b"]
| "array"
| "array"


| bool(true)
| true


| int(1)
| int(1)
Строка 377: Строка 363:
| float(1)
| float(1)


| style="background-color: #ffff66"| "Array"
| style="background-color: #ffff66" | '''"Array" *'''
| ["a"=>"b"]
| ["a"=>"b"]
| {"a":"b"}*
| {"a":"b"}**
|-
|-
! [["a"=>"b"]]
! [["a"=>"b"]]
| "array"
| "array"


| bool(true)
| true


| int(1)
| int(1)
Строка 390: Строка 376:
| float(1)
| float(1)


| style="background-color: #ffff66"| "Array"
| style="background-color: #ffff66" | '''"Array" *'''
| [["a"=>"b]]
| [["a"=>"b]]
| {"0":["a"=>"b"]}*
| {"0":'''["a"=>"b"]'''}**
|-
|-
! new stdClass()
! new stdClass()
| "object"
| "object"


| bool(true)
| '''true'''


| style="background-color: #ffff66"| int(1)
| style="background-color: #ffff66" | '''int(1)*'''
| style="background-color: #ffff66"| float(1)
| style="background-color: #ffff66" | float(1)*
| style="background-color: #ff6666"| ERROR!
| style="background-color: #ff6666" | '''ERROR!***'''
| []
| [ ]
| {}*
| { }**
|-
|-
! new class {function __toString(){
! <small>Object с методом __toString</small>
<nowiki>return "value"; }}</nowiki>
| "object"
| "object"


| bool(true)
| true


| style="background-color: #ffff66"| int(1)  
| style="background-color: #ffff66" | int(1)*


| style="background-color: #ffff66"| float(1)
| style="background-color: #ffff66" | float(1)*


| "value"
| "''<small>из __toString</small>''"


| []
| [<small>''поля из объекта''</small>]
| object(class@anonymous)
| ''object(SomeClass)''
|-
|-
! (function() { yield 1; yield 2; })()
! <small>(function() { yield ...; })()</small>
| "object"
| "object"


| bool(true)
| true


| style="background-color: #ffff66"| int(1)
| style="background-color: #ffff66" | int(1)*


| style="background-color: #ffff66"| float(1)
| style="background-color: #ffff66" | float(1)*
| style="background-color: #ff6666"| ERROR!
| style="background-color: #ff6666" | '''ERROR!***'''
| []
| [ ]
| object(Generator)
| ''object(Generator)''
|-
|-
! fopen('file', 'r')
! fopen('xxx', 'r')
| "resource"
| "resource"


| bool(true)
| true


| int(6)
| '''int(?)'''


| float(6)
| '''float(?)'''


| "Resource id #6"
| "<small>Resource id #?</small>"


| [resource(6)…]
| [<small>''resource…''</small>]


| {"scalar":resource(6)…}
| {"scalar":''<small>resource…</small>''}


|-
|-
! Примечания:
! <sub>Примечания:</sub>
|colspan="2" style="background-color: #ffff66"| E_WARNING
| colspan="2" style="background-color: #ffff66" | <sub>* E_WARNING</sub>
|colspan="3"| * { } - обозначение для object(stdClass)
| colspan="3" | <sub>** { } - обозначение для object(stdClass)</sub>
|colspan="2" style="background-color: #ff6666"| E_RECOVERABLE_ERROR
| colspan="2" style="background-color: #ff6666" | <sub>*** E_RECOVERABLE_ERROR</sub>
|-
|-
|}
|}