Skip to content

Instantly share code, notes, and snippets.

@codenamegary
Last active April 19, 2017 15:39
Show Gist options
  • Save codenamegary/bf0fd370d61480c57744416448aa4a58 to your computer and use it in GitHub Desktop.
Save codenamegary/bf0fd370d61480c57744416448aa4a58 to your computer and use it in GitHub Desktop.
Random PHP code
<?php
public function pdf_creation($content)
{
if (false !== file_put_contents($this->full_file_name, $content)) {
return true;
}
while (substr($this->filename, 0, 1) === '.') {
$this->filename .= substr($this->filename, 1, (strlen($this->filename) - 1));
}
return false !== file_put_contents($this->filename, $content);
}
/********************************************************/
$balance = intval((string)($price * 100));
/********************************************************/
if (validateP() === true)
if (validateI() === true)
if (validateR() === true)
if (validateD() === true)
if (validateC() == true)
if (validateN() == true)
if (validateB() == true)
if (validateP() == true) {
if (validateS() == true) {
if (..some code..) {
return false;
} else {
variable = true;
}
}
} else {
alert("Wrong data.");
}
/********************************************************/
$objService = new \SomeService($mysqli, "{$record['username']}" , "{$record['pwd']}" , "{$record['companyid']}");
/********************************************************/
$stupidStrToTimeValue = strtotime('now');
/********************************************************/
if (isset($_GET['button']) && (!$_GET['note_text'] == "")) {
/********************************************************/
/*
* Pending for later
*/
if (!($dset->count() > 0) && 1 == 0) {
/********************************************************/
function isNotEmpty($value)
{
return !empty($value);
}
/********************************************************/
if ($object->updateRecord($_POST) == true) {
echo 1;
} else {
echo 0;
}
/********************************************************/
//TEMPORAL PATCH
^ comment from < 2013
/********************************************************/
if ($_C_TYPE == 'II' && $print == 'Y' && ($order == false || $print == 'Y')) {
/********************************************************/
if (count($list > 0) && count($items) <=0) {
/********************************************************/
<?=not_so_full_url();?>
/********************************************************/
$safeVal = htmlspecialchars(strip_tags($_GET['userid']));
$update = "Update users set is_admin = 1 WHERE userid = $safeVal");
$db->Execute($update);
^ This variable name is safeVal so no need to worry
/********************************************************/
$updates = array();
foreach ($_POST as $key => $value) {
array_push($updates, "$key = '$value'");
}
$sql = "UPDATE some_table SET " . join($updates, ', ') . " WHERE id = '{$id}'";
$db->Execute($sql);
^ ^^
/********************************************************/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment