php basics for designers

Download PHP Basics for Designers

If you can't read please download the document

Upload: matthew-turland

Post on 10-Jun-2015

3.661 views

Category:

Technology


0 download

TRANSCRIPT

  • 1. PHP Basics for Designers
      • Matthew Turland
    • Atlanta Web Designers Group
    • November 11, 2008

2. So what is PHP?

    • A programming language.
    • Mainly intended for web applications.
    • Also useful for other things.
    • That last part is another story for another time...

3. Let's jump right in...

    • These do the same thing.
    • Hello world!

4. How is that useful?

    • When 'Hello world!' could be anything.
    • ...
    • Result :

      Goodbye cruel world!

5. Can you break that down?

opening PHP tag variable assignment operator string (quote to quote) closing PHP tag end of statement 6. A little shorter, maybe?

    • These do the same thing.
    • For #2, short_open_tag must be on.

7. Now you see me...

    • The HTML here is displayed.
    • ...
    • ...

8. ... and now you don't.

    • The HTML here isnotdisplayed.
    • ...
    • ...

Here's why 9. On one condition...

    • ...

comparison operator == for is != for is not 10. Playing with strings

    • These all result in the same output.
    • echo 'Hello'.' '.'world!';
    • $greeting = 'Hello';
    • echo $greeting.' '.'world!';
    • $object = 'world';
    • echo $greeting.' '.$object.'!';

concatenation operator (combines strings) 11. Building strings

    • These do the same thing.
    • $greeting = 'Hello';
    • $greeting= $greeting .' world!';
    • $greeting = 'Hello';
    • $greeting.=' world!';

12. All for one...

    • Your standard HTML list.
    • Milk
    • Eggs
    • ...
    • Bread

13. ... one for all.

    • The same list of items in PHP.
    • ...

14. Adding a dimension...

row column key value 15. ... and displaying it.

    • >

16. The results are in!

    • Exciting New Headline
    • News from yesterday

17. The not-so-great wall

    • http://example.com/foo.php?title=
    • Result :
    • Most likely, this is not good for security.

18. The great escape

    • http://example.com/foo.php?title=
    • Result :

      ...

    • Rendered result:

19. Stylish yet functional

    • Functions are reusable bits of code.
    • function ul($items) {
    • $result = '
      • ';
    • foreach ($items as $item) {
    • $result .= '
    • ' . htmlspecialchars($item) . '';
    • }
    • return $result . '
    ';
    • }

20. Call me

    • This...
    • ... becomes this...
      • Milk
      • Eggs
      • Bread

21. Plug and play Content 22. Want to learn more?

    • http://php.net/manual/en
    • http://phpcommunity.org
    • irc://irc.freenode.net/phpc
    • http://phpwomen.org
    • irc://irc.freenode.net/phpwomen
    • http://phpbuilder.com/board
    • http://www.amazon.com/dp/0596005601

23. To sum it up...

    • Avoid copy and paste. Includes and functions!
    • Before outputting variables, escape them!
    • PHP has lots of built-in functions. Use them!
    • Don't let your learning about PHP stop here!

24. Questions?