Awesome PHP has been relocated permanently to its own Github repository. No further updates will made to this gist.
Please open an issue for any new suggestions.
| <?php | |
| $date = new DateTime('now'); | |
| echo $date->format('d/m/Y').PHP_EOL; // format: day/month/year | |
| echo $date->format('m-d-Y').PHP_EOL; // format: month-day-year | |
| echo $date->format('Y-m-d').PHP_EOL; // format: year-month-day | |
| // add 3 days to current date and output using format year-day-month | |
| echo $date->setTimestamp( strtotime('+3 days', $date->getTimestamp()) )->format('Y-d-m'); |
| <?php | |
| /** | |
| * Ranking Library | |
| * contains alogrithms for story ranking | |
| * Basically a PHP Implementation of reddits algorithms | |
| * | |
| * @author Lucas Nolte <lnolte@i.biz> | |
| * @since 0.1 | |
| * @package Polska Wiadomosc | |
| * @subpackage Libraries |
| <?php | |
| class DocBlock { | |
| public $docblock, | |
| $description = null, | |
| $all_params = array(); | |
| /** | |
| * Parses a docblock; |
| #!/bin/bash | |
| ########## | |
| ## Setup: hardcode your mysql user/pass. Yeah, yeah, I know...it's frowned upon. | |
| ## but for local development, I have no problem with it. | |
| ## Find and replace: MYSQLUSER / MYSQLPASS | |
| ## | |
| ## Usage: This script accepts only one variable, the site name. | |
| ## | |
| ######### |
Awesome PHP has been relocated permanently to its own Github repository. No further updates will made to this gist.
Please open an issue for any new suggestions.
| <?php | |
| /** | |
| * Here is a non-magic-method version for those that need better auto-complete and faster access times. | |
| * It also filters the input to be valid UTF-8 just when needed thanks to phunction. | |
| */ | |
| class input | |
| { | |
| public static $encoding = 'UTF-8'; | |
| public static function server($key, $default = NULL, $control = true) |
| /** | |
| * Git Pull | |
| * | |
| * @author Adam Patterson | |
| * http://www.adampatterson.ca/blog/2011/10/diy-simple-staging-server/ | |
| * | |
| * Use: echo pull(); | |
| */ | |
| function pull ( ) |
| RED="\[\033[0;31m\]" | |
| YELLOW="\[\033[0;33m\]" | |
| GREEN="\[\033[0;32m\]" | |
| BLUE="\[\033[0;34m\]" | |
| LIGHT_RED="\[\033[1;31m\]" | |
| LIGHT_GREEN="\[\033[1;32m\]" | |
| WHITE="\[\033[1;37m\]" | |
| LIGHT_GRAY="\[\033[0;37m\]" | |
| COLOR_NONE="\[\e[0m\]" |