Changeset 142857
- Timestamp:
- 08/04/2009 10:25:31 PM (17 years ago)
- Location:
- php-shortcode
- Files:
-
- 2 edited
-
tags/1.3/README.txt (modified) (6 diffs)
-
trunk/README.txt (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
php-shortcode/tags/1.3/README.txt
r142855 r142857 17 17 = Usage = 18 18 19 The plugin provides two pairs of shortcodes - `[php]code[/php]` and `[echo]code[/echo]`. these two pairs of shortcodes resembles the functionality of the `<?php code ?>` and `<?= code ?>` tags in a normal lyPHP script, respectively.19 The plugin provides two pairs of shortcodes - `[php]code[/php]` and `[echo]code[/echo]`. these two pairs of shortcodes resembles the functionality of the `<?php code ?>` and `<?= code ?>` tags in a normal PHP script, respectively. 20 20 21 21 22 22 For example: 23 23 24 The answer to the <em>ultimate</em> math challenge, <strong>1+2</strong>, is... 24 25 [php] … … 31 32 32 33 Will become: 34 33 35 The answer to the <em>ultimate</em> math challenge, <strong>1+2</strong>, is... 34 36 3 … … 43 45 44 46 Although I said the shortcode pairs resembles a `<?php code ?>` tag pair, there is an important difference. The PHP code in the shortcodes are executed in a "throw-away" local namespace, instead of the global one. All variables defined in a `[php] code [/php]` block **cannot** be accessed outside the block. Therefore, this will not work: 47 45 48 [php] 46 49 $a = 1; … … 52 55 53 56 And neither would this: 57 54 58 [php] 55 59 $my_array = array('apple','orange'); … … 64 68 65 69 To work around the first problem, you may use the `global` keyword: 70 66 71 [php] 67 72 global $a, $b; … … 74 79 75 80 And to work around the second problem, you may use "real" PHP closing tags within your `[php] code [/php]` block to switch between PHP and HTML mode: 81 76 82 [php] 77 83 $my_array = array('apple','orange'); -
php-shortcode/trunk/README.txt
r142855 r142857 17 17 = Usage = 18 18 19 The plugin provides two pairs of shortcodes - `[php]code[/php]` and `[echo]code[/echo]`. these two pairs of shortcodes resembles the functionality of the `<?php code ?>` and `<?= code ?>` tags in a normal lyPHP script, respectively.19 The plugin provides two pairs of shortcodes - `[php]code[/php]` and `[echo]code[/echo]`. these two pairs of shortcodes resembles the functionality of the `<?php code ?>` and `<?= code ?>` tags in a normal PHP script, respectively. 20 20 21 21 22 22 For example: 23 23 24 The answer to the <em>ultimate</em> math challenge, <strong>1+2</strong>, is... 24 25 [php] … … 31 32 32 33 Will become: 34 33 35 The answer to the <em>ultimate</em> math challenge, <strong>1+2</strong>, is... 34 36 3 … … 43 45 44 46 Although I said the shortcode pairs resembles a `<?php code ?>` tag pair, there is an important difference. The PHP code in the shortcodes are executed in a "throw-away" local namespace, instead of the global one. All variables defined in a `[php] code [/php]` block **cannot** be accessed outside the block. Therefore, this will not work: 47 45 48 [php] 46 49 $a = 1; … … 52 55 53 56 And neither would this: 57 54 58 [php] 55 59 $my_array = array('apple','orange'); … … 64 68 65 69 To work around the first problem, you may use the `global` keyword: 70 66 71 [php] 67 72 global $a, $b; … … 74 79 75 80 And to work around the second problem, you may use "real" PHP closing tags within your `[php] code [/php]` block to switch between PHP and HTML mode: 81 76 82 [php] 77 83 $my_array = array('apple','orange');
Note: See TracChangeset
for help on using the changeset viewer.