PHP code must always be delimited by the full-form, standard PHP tags and be terminated with semicolon:
<?php
$model = $web->getModel();
$title = $model->getTitle();
?>For single-line statements:
| # Create new user - useradd | |
| # -s SHELL : The name of the user's login shell | |
| # -m : Create user’s home directory if it does not exist | |
| # -d HOME_DIR : Home directory of the new user | |
| # -c COMMENT : Some description of user | |
| # -g GROUP : Group name of the new user | |
| # USERNAME : Name of the new user | |
| # | |
| # And here is an example: |
| # Check out Rails::Generators::GeneratedAttribute::default | |
| when :integer then 1 | |
| when :float then 1.5 | |
| when :decimal then "9.99" | |
| when :datetime, :timestamp, :time then Time.now.to_s(:db) | |
| when :date then Date.today.to_s(:db) | |
| when :string then name == "type" ? "" : "MyString" | |
| when :text then "MyText" | |
| when :boolean then false |
| tail -f filename.ext | nl |
| var delay = (function() { | |
| var timer = 0; | |
| return function(callback, ms) { | |
| if (typeof(callback) == 'function' && typeof(ms) == 'number') { | |
| clearTimeout(timer); | |
| timer = setTimeout(callback, ms); | |
| } | |
| } | |
| })(); |
| // Original source http://lummie.co.uk/javascript-%E2%80%93-rails-like-pluralize-function/ | |
| var pluralize = (function() { | |
| var Inflector = { | |
| Inflections: { | |
| plural: [ | |
| [/(quiz)$/i, "$1zes" ], | |
| [/^(ox)$/i, "$1en" ], | |
| [/([m|l])ouse$/i, "$1ice" ], | |
| [/(matr|vert|ind)ix|ex$/i, "$1ices" ], |
| <?php | |
| set_include_path(implode(PATH_SEPARATOR, array( | |
| realpath(APPLICATION_PATH . '/../../libraries/'), | |
| realpath(APPLICATION_PATH . '/../../etc/'), | |
| // ... | |
| // Some other stuff | |
| // ... | |
| get_include_path() |
| for filename in list | |
| do (filename) -> | |
| # ... |
| <?php | |
| //User role checking for contacts | |
| $contacts = 0; | |
| $type = explode(',',$data['sp_user_type']); | |
| $contactsArray = array('1','2','3','4','5','6','7','8','9','10'); | |
| foreach($contactsArray as $contactsArr){ | |
| if(in_array($contactsArr,$type)){ | |
| $contacts = 1 ; | |
| } |
| <?php | |
| switch (true) { | |
| case ($a > $b): | |
| //... | |
| break; | |
| case ($a > $c): | |
| //... | |
| break; |