Cfphp Zce 01 Basics

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    1 Favorite

    Cfphp Zce 01 Basics - Presentation Transcript

    1. CFPHP ZCE Training Session One: PHP Basics 1
    2. In Today’s Episode • • PHP Files Summary • • Data Types Useful Resources • Variables & Constants • Operators • Control Structures • Errors 2
    3. PHP Files 3
    4. Scripts • Default Extension: .php • May be Overridden via Server Conf • Not Compiled, Interpreted • Thus, PHP is a text-processing language 4
    5. Tags • Standard Tags • <?php ?> • Short Tags • <? ?> 5
    6. Tags • Script Tags • <script language=“PHP”></script> • ASP Tags • <% %> • * Standard tags are the only recommendation 6
    7. Newlines • Interpreter removes newlines at end of all scripts • This prevents “Headers Already Sent” errors 7
    8. Statement Termination • Semicolons terminate PHP statements • function_call(); • $a = 123; • There are few exceptions • Control Structures • Last Line in PHP Script 8
    9. Comments • // Inline Comment • # PERL Style Comment • /* C Style Multiline Comment */ 9
    10. Whitespace • PHP = Loosely Typed • Whitespace is usually ignored • Exceptions: • Opening/Closing Tags • Keywords • Functions/Variable Names 10
    11. Code Blocks • Defined by { Curly Braces } • Groups code into related blocks • Runs under specific circumstances • Functions • Conditionals • Loops 11
    12. Language Constructs • Similar to Functions... different rules • if(), while(), for(), foreach(), function() • echo() vs print() • die(), exit() 12
    13. Data Types 13
    14. Data Types • 2 Main Categories • Scalar Values • Compound Values 14
    15. Data Types • Numeric Types • Integer • Floating Point 15
    16. Data Types • Integers • Sined values only • Defined Via • Decimal Notation • Octal Notation • Hexadecimal Notation 16
    17. Data Types • Floating Point • AKA: Doubles, Floats • Defined Via: • Decimal Notation • Exponential Notation 17
    18. Data Types • Strings • Junkdrawers for Binary Data (Usually Text) • Single Quotes = Simple Strings • Double Quotes = Complex Strings • Heredoc = Long Complex Strings 18
    19. Data Types • Booleans • TRUE • FALSE 19
    20. Data Types • Compound Data Types • Array • Object 20
    21. Data Types • Other Data Types • null • Resources 21
    22. Variables & Constants 22
    23. Syntax • Defined by $ • Names may be alpha-numeric • May contain underscores • May NOT begin with a Number 23
    24. Variable Variables • Variable Name becomes a variable • Generally not recommended • Code Difficult to read 24
    25. Variable Existance • isset() 25
    26. Constants • Similar to variables, but not • Values Stored once, may never be changed • Names are suggested to be in ALL_CAPS • define(), defined() 26
    27. Operators 27
    28. Arithmetic • Addition: + • Subtraction: - • Multiplication: * • Division: / • Modulus: % 28
    29. Arithmetic • Increment Before: ++$a • Increment After: $a++ • Decrement Before: --$a • Decrement After: $a-- 29
    30. String Concatenation • Period is only Concatenation Operator • Two Ways to Concatenate • $c = $a . $b; • $a .= $b; 30
    31. Assignment • Simple Assignment • Arithmetic/Bitwise Assignment • $a += $b; • $a *= $b; 31
    32. References • $a = 4; $b = $a; $a = 6; echo $b; 32
    33. References • $a = 4; $b &= $a; $a = 6; echo $b; 33
    34. References • Scalar Values and Arrays are always COPIED • Objects are Passed Via Reference 34
    35. Comparison • Results of Comparison Operations are ALWAYS boolean • Equal == • Identical === • Not Equal != • Not Identical !== 35
    36. Comparison • Less Than < • Greater Than > • Less Than or Equal To <= • Greater Than or Equal To >= 36
    37. Logical • NOT ! • AND && / and • OR || / or • XOR 37
    38. Other • Error Control Operator @ • @mysql_connect(‘foo’, ‘bar’, ‘beer’); • Backtick • $a = `ls -la`; 38
    39. Control Structures 39
    40. Conditionals • if • else • elseif • Ternary • $a = (isset($b)) : ‘mike’ ? ‘chris’; 40
    41. Loops • while • do...while • for • break / continue 41
    42. Errors 42
    43. Error Levels • Compile Time • Errors occured during script compilation. • Script execution is halted 43
    44. Error Levels • Fatal Errors • Errors in syntax, etc. • Script execution is halted 44
    45. Error Levels • Recoverable Errors • Significant failures • Can still run in a safe way 45
    46. Error Levels • Warnings • Recoverable errors. • Script execution continues 46
    47. Error Levels • Notices • Generally small errors. IE Undefined variables, etc. • Script execution continues 47
    48. Error Reporting • php.ini Directives • error_reporting • display_errors • log_errors 48
    49. Handling Errors • set_error_handler() 49
    50. Questions? 50
    51. Useful Resources 51
    52. Reading • ZEND PHP 5 Certification Study Guide http://www.phparch.com/shop_product.php?itemid=135 • Programming PHP http://en.wikibooks.org/wiki/PHP • Practical PHP Programming http://hudzilla.org/phpwiki/index.php?title=Main_Page • The PHP Manual http://us2.php.net/manual/en/ 52

    + Michael GirouardMichael Girouard, 3 years ago

    custom

    1512 views, 1 favs, 1 embeds more stats

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 1512
      • 1511 on SlideShare
      • 1 from embeds
    • Comments 0
    • Favorites 1
    • Downloads 29
    Most viewed embeds
    • 1 views on http://192.168.10.100

    more

    All embeds
    • 1 views on http://192.168.10.100

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories

    Tags