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
/** | |
* @package javascriptApp | |
* @author Adrian Testa-Avila <[email protected]> | |
* @copyright 2012 Adrian Testa-Avila | |
* @license Creative Commons Attribution-ShareAlike 3.0 Unported | |
* <http://creativecommons.org/licenses/by-sa/3.0/> | |
*/ | |
/** | |
* jQuery plugin: AT.autoXHR |
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 | |
/* | |
Not trying to be a complete MVC implementation, obviously, | |
just a good, easy-to-implement introduction for the average PHP coder/hobbyist. | |
It WILL make your scripts BETTER! :) | |
The basic rule is "PHP-FIRST": | |
meaning, don't end php ?>, do some html, and then start <?php again. | |
PHP doesn't *actually* work this way, | |
(you can't "start," "stop," and "start again": breaking into HTML is pretty much the same as echo'ing it) |
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 | |
/** | |
* models a bitfield and provides manipulation & comparison methods. | |
* | |
* @author Adrian Testa-Avila <[email protected]> | |
* @copyright 2012 | |
* @license MIT License [http://opensource.org/licenses/MIT] | |
*/ | |
class Bitfield{ |
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 | |
/** | |
* wraps info returned from twitter's "sign in with twitter" API. | |
* add additional methods/properties as desired and use as a user class. | |
* | |
* @author Adrian Testa-Avila <[email protected]> | |
* @copyright 2013 Adrian Testa-Avila | |
* @license creative commons attribution-sharealike | |
* http://creativecommons.org/licenses/by-sa/3.0/ | |
* |
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 | |
die(); # WHY WONT IT |
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 | |
// you can't just get this as JSON in the first place, can you ...? | |
$xml = simplexml_load_file( "http://readability.com/christopherburton/latest/feed" ); | |
$json = json_encode( $xml ); | |
$array = json_decode( $json,TRUE ); | |
$items = $array['channel']['item']; | |
// we're doing this now so we can sanitize the data without requiring a second loop | |
// (substitute your actual DB credentials) | |
$DB = new mysqli( DB_HOST,DB_USER,DB_PASS,DB_NAME ); |
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 | |
/* | |
You don't need ReflectionClass at all - just make an interface for your classes to follow. | |
Define all the methods that you require of your classes for this situation. | |
*/ | |
interface iA{ | |
// (modified init signature to include args you pass in your example) | |
public function init( $request,$response ); |
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 | |
/** | |
* performs validation on a variable, returning the variable's value on success. | |
* | |
* @author Adrian <[email protected]> | |
* @copyright 2013 | |
* @since 2014-08-21 allows a validator callback | |
* @license MIT <http://opensource.org/licenses/MIT> | |
* |
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
<?= strip_tags('I <3 WordPress') ?> |
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 | |
// I first saw this on freenode/##php, from Viper-7. | |
// first, make an array with ALL of the field names you expect, and default values for each. | |
// keys are field names; values are field defaults. | |
$defaults = [ | |
"field1" => "default value", | |
"field2" => "", // ← default is empty string | |
"field3" => null // ← no default value |
OlderNewer