Skip to content

Instantly share code, notes, and snippets.

@PeeHaa
PeeHaa / gist:6103398
Created July 29, 2013 10:17
Crap PHP tutorials
- http://www.phptutorialforbeginners.com/2012/10/php-simple-login-form-php-tutorial-for.html
@PeeHaa
PeeHaa / xpath_match_all
Last active December 11, 2015 04:38 — forked from gooh/xpath_match_all
<?php
function xpath_match_all($query, $html = '')
{
static $dom;
static $xpath;
static $content;
if (!$dom) {
$dom = new DOMDocument;
}
@PeeHaa
PeeHaa / so-chat-default-pinned.md
Created November 26, 2012 10:48
Stackoverflow PHP chat default pinned message
cv-pls: [Backlog](http://cvbacklog.gordon-oheim.biz/) ([mirror](http://cvbacklog.herokuapp.com/)) | [Meaning](http://gist.github.com/1689430) | [Chrome/Firefox Addon](https://github.com/cv-pls/) | [Cat Content](http://goo.gl/i04rR) | Snippets: [Mysql](https://gist.github.com/3881905) | Reference: [Errors](http://stackoverflow.com/q/12769982/367456) | [Operators](http://stackoverflow.com/questions/3737139/reference-what-does-this-symbol-mean-in-php)

cv-pls: Backlog (mirror) | Meaning | Chrome/Firefox Addon | Cat Content | Snippets: Mysql | Reference: Errors | Operators

@PeeHaa
PeeHaa / pdo.php
Created September 14, 2012 17:23
PDO
<?php // always use full php tags
//require 'connect.inc.php';
$dbConnection = new PDO('mysql:dbname=dbtest;host=127.0.0.1;charset=utf8', 'user', 'pass');
$dbConnection->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
$dbConnection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
// mysql_* function?? Eeeeek
function query($query)
{
@PeeHaa
PeeHaa / troubles.md
Created August 8, 2012 22:33
soundcloud api troubles
<?php
function curPageURL() {
 $pageURL = 'http';
 if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
 $pageURL .= "://";
 if ($_SERVER["SERVER_PORT"] != "80") {
  $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
 } else {
  $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];

}

@PeeHaa
PeeHaa / tutorial-function.md
Created July 30, 2012 14:25
function for tutorial

Functions

PHP already has a lot of [built-in functions][builtin-functions]. Besides the built-in functions already provided by PHP it is also possible to define your own functions. Functions can be used to run the same code multiple times without having to add the code multiple times. It can also be used to organize your code. Generally speaking a function is a piece of code with an input, some defined actions based on the input and an output. An example of function that calculates the differences in the age of two people is:

function getAgeDifference($age1, $age2)
{
    return abs($age1 - $age2);
}
@PeeHaa
PeeHaa / technical-references-for-questions.md
Created July 27, 2012 09:06
Technical references for questions
@PeeHaa
PeeHaa / mysql.md
Created July 27, 2012 08:57
Ancient mysql_* default message
[**Please, don't use `mysql_*` functions in new code**](http://bit.ly/phpmsql). They are no longer maintained [and are officially deprecated](https://wiki.php.net/rfc/mysql_deprecation). See the [**red box**](http://j.mp/Te9zIL)? Learn about [*prepared statements*](http://j.mp/T9hLWi) instead, and use [PDO](http://php.net/pdo) or [MySQLi](http://php.net/mysqli) - [this article](http://j.mp/QEx8IB) will help you decide which. If you choose PDO, [here is a good tutorial](http://j.mp/PoWehJ).

Please, don't use mysql_* functions in new code. They are no longer maintained and are officially deprecated. See the red box? Learn about prepared statements instead, and use PDO or MySQLi - this article will help you decide which. If you choose PDO, here is a good tutorial.

@PeeHaa
PeeHaa / politics.md
Created July 12, 2012 10:24
Politics that matter
  • data retention
  • net neutrality
  • SOPA stance
  • PTT stance
  • patent reform
  • privacy
  • censorship
  • "white hats" / whitsleblowers
  • data leaks
  • copyright reform