Skip to content

Instantly share code, notes, and snippets.

@dave-jay
dave-jay / curl
Created May 14, 2013 07:00
PHP Curl function to open url
function _gu($url) {
$ch = curl_init();
$timeout = 5;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:18.0) Gecko/20100101 Firefox/18.0');
$data = curl_exec($ch);
@dave-jay
dave-jay / dave_escape.php
Last active December 16, 2015 14:39
Escape in php to stop throwing 'undefined index/var' notice while using var directly
<?php
function _e(&$a,$return=NULL){
return isset($a) ? $a : $return;
}
// usages
# scenario #1
$field = _e($_GET['field']);
# if field is not set, it will be set to null