Advertisement
Guest User

Untitled

a guest
Nov 24th, 2014
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. <!doctype html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Untitled Document</title>
  6. </head>
  7.  
  8. <body>
  9. <?php
  10. $str = <<<EOD
  11. Example of string
  12. spanning multiple lines
  13. using heredoc syntax.
  14. EOD;
  15.  
  16. /* More complex example, with variables. */
  17. class foo
  18. {
  19. var $foo;
  20. var $bar;
  21.  
  22. function foo()
  23. {
  24. $this->foo = 'Foo';
  25. $this->bar = array('Bar1', 'Bar2', 'Bar3');
  26. }
  27. }
  28.  
  29. $foo = new foo();
  30. $name = 'MyName';
  31.  
  32. echo <<<EOT
  33. My name is "$name". I am printing some $foo->foo.
  34. Now, I am printing some {$foo->bar[1]}.
  35. This should print a capital 'A': x41
  36. EOT;
  37. ?>
  38. </body>
  39. </html>
  40.  
  41. <?php
  42.  
  43. class ViewModel {
  44. public function sayHello($name = null) {
  45. if (is_null($name))
  46. {
  47. $name = 'World';
  48. }
  49.  
  50. return sprintf('Hello %s', $name);
  51. }
  52. }
  53.  
  54. <?php
  55. require_once('viewmodel.php');
  56. $model = new ViewModel();
  57. ?>
  58.  
  59. <!doctype html>
  60. <html>
  61. <head>
  62. <meta charset="utf-8">
  63. <title>Untitled Document</title>
  64. </head>
  65.  
  66. <body>
  67. <?php echo $model->sayHello(); ?>
  68. </body>
  69. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement