Skip to content

Instantly share code, notes, and snippets.

<?php
ini_set('display_errors', '1');
$memcache = new Memcache;
$memcache->connect('orchestra-io.pjekkp.0001.use1.cache.amazonaws.com', 11211);
($memcache->add('testkey', 'It worked!')? "Added data." : "There was a problem adding data.") . "<br/>";
($memcache->get('testkey')?: "This should have worked") . "<br/>";
<?php
if (!(
isset($_SERVER['PHP_AUTH_USER'])
&& 'username' == $_SERVER['PHP_AUTH_USER']
&& isset($_SERVER['PHP_AUTH_PW'])
&& sha1('password') == sha1($_SERVER['PHP_AUTH_PW'])
)) {
header('WWW-Authenticate: Basic realm="Orchestra"');
header('HTTP/1.0 401 Unauthorized');
echo "You must authenticate to use this site.\n\n";
<?php
usleep(100000);
<?php
header("X-Orchestra-Server: app1-new");
phpinfo();
<?php
var_dump($_SERVER['HTTP_HOST']);
function TestController() {
var iansFunction = function() { return true; }
iansFunction(); // returns true
}
iansFunction(); // returns uncallable
@SemanticallyNull
SemanticallyNull / filter_var.php
Created November 9, 2012 15:14
filter_var() example
<?php
$options = array('options'=>array(
'min_range' => 1,
'max_range' => 5,
'default' => 3
));
$_GET['grievous'] = filter_var($_GET['grievous'], FILTER_VALIDATE_INT, $options);
<?php
var_dump(! empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off');
<?php
echo "Some test stuff";
trigger_error("This is a test - trigger_error()", E_USER_ERROR);
syslog(LOG_ERR, "This is a test - syslog()");
<?php
echo "Domain 2";