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 | |
// Clean PHP session files when you have 10,000s of them! | |
// Set this to the folder that contains your session files with trailing slash | |
// @see http://php.net/manual/en/function.session-save-path.php | |
$sessionTmpFolder = '/path/to/tmp/'; | |
$x=0; | |
foreach (range(0,9) as $number) { | |
foreach (range('a','z') as $letter) { |
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
// Go back link functionality | |
// Requires HTML link with id="back-to-last-page" which is hidden by default with display: none; | |
if (window.history && window.history.pushState) { | |
// Only display if referrer matches current hostname | |
var matchHostname = new RegExp('http(s)?:\/\/' + window.location.host); | |
if (matchHostname.test(document.referrer)) { | |
// Show link and go back via History API |
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 | |
// Read CSV file | |
// PHP5.4+ | |
ini_set('auto_detect_line_endings', true); | |
$file = new SplFileObject("path/to/file.csv"); | |
$file->setFlags(SplFileObject::READ_CSV); | |
$line = 0; | |
$headers = []; | |
foreach ($file as $row) { |
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 | |
// Error reporting | |
error_reporting(E_ALL); | |
ini_set('display_errors', true); | |
// Return the Apache user | |
$tmpFilename = tempnam('/tmp', 'TEST'); | |
$handle = fopen($tmpFilename, 'w'); | |
fwrite($handle, 'testdata'); | |
fclose($handle); |
NewerOlder