This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* In this example, we are autoloading classes within the namespace `Acme\ExampleProject`. The file `index.php` is the | |
* entry point to our project; and we are using the `src` directory to store and organize our PHP class files. Our | |
* autoloader is located in `autoload.php` | |
* | |
* The basic behavior is illustrated in the fact that PHP will autoload the file `src/mammals/human.php` whenever we | |
* attempt to create a `new \Acme\ExampleProject\Mammals\Human` anywhere in our project's codebase. | |
* | |
* This diagram illustrates our project structure. Each file's contents can be found below. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
/** | |
* An example function in JavaScript | |
* | |
* @param int myInt | |
* @param string myString | |
* | |
* @return string | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* This function has no inputs, so it is not a function from a mathematical | |
* perspective. Furthermore, the function is not predictable because it depends on | |
* the state of the underlying program | |
*/ | |
function say_hello() { | |
$name = 'World'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function f( $x ) { | |
return $x+5; | |
} | |
function g( $x ) { | |
return $x+1; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
# Make sure to replace {id} with your form's id | |
add_filter( 'gform_pre_render_{id}', 'my_populate_checkbox' ); | |
function my_populate_checkbox( $form ) { | |
/** | |
* Loop through form fields | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component } from '@angular/core'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var coinTosses = [ | |
{ isHeads: true, user: 'Michael', time: 1485954569 }, | |
{ isHeads: false, user: 'Michael', time: 1485954575 }, | |
/* ... etc ... */ | |
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* In the `person.sayHello` function, we are using an ES6 template literal | |
* to dynamically create a string | |
*/ | |
var person = { | |
first: 'Michael', | |
last: 'Hull', | |
sayHello: function() { | |
console.log( `Hi, my name is ${this.first} ${this.last}` ); | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Key template --> | |
<script type='text/html' id='key-template'> | |
<kbd>{{ key.key }}</kbd> | |
<span class='sound'>{{ key.name }}</span> | |
<audio src="sounds/{{ key.name }}.wav"></audio> | |
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
#! /acme-plugin/acme-plugin.php | |
/** | |
* Plugin Name: ACME Plugin | |
* Description: A WordPress plugin example using PHP namespaces and autoloading | |
* Version: 0.0.0 | |
* Author: Michael Hull | |
* Author URI: https://resoundingechoes.net | |
*/ |
NewerOlder