lecture23

lecture23 - PIC 40A Lecture 23: More PHP Fundamentals PHP...

Info iconThis preview shows pages 1–7. Sign up to view the full content.

View Full Document Right Arrow Icon
PIC 40A Lecture 23: More PHP Fundamentals
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
PHP Scalar Conversions • Variables are determined by the context of the expression • implicit conversions (coercions) –NULL coerced to 0 , “”, or FALSE – 0.0 is coerced to FALSE – 0 is coerced to FALSE ; – nonzero values coerced to TRUE –“” , “0” , and "0.0" are FALSE , otherwise TRUE
Background image of page 2
PHP Scalar Conversions • implicit conversions (coercions) – string to integer,double: • if does not begin with a digit, coerced to 0 • non-numeric chars after the integer are ignored • strings containing . , e , or E are coerced to doubles, otherwise they become integers – double to integer • fractional part truncated, not rounded
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
PHP Scalar Conversions • explicit conversions use settype eg $a = 2.8; settype($a, "integer"); #2 settype($a, "string"); #"2" settype($a, "boolean"); #TRUE settype($a, "double"); #1
Background image of page 4
PHP Constants • to define a constant use define eg define("VALUE", 5); $a = VALUE + 3; define("SCHOOL", "UCLA"); print( SCHOOL );
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
PHP operators • Arithmetic +, -, *, /, ++, --, % • Relational ==, ===, !=, <>, !==, <, >, <=, >= • String concatenation . , repetition str_repeat($str, $multiplier) , character access: $str[3] // char at index 3 • Boolean •T e r n a r y ?: (same as C++)
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 03/15/2010 for the course PIC 40A taught by Professor Ouellette during the Winter '10 term at UCLA.

Page1 / 23

lecture23 - PIC 40A Lecture 23: More PHP Fundamentals PHP...

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online