Last active
April 14, 2020 13:35
-
-
Save Retter241/c6693d5c3d32b080010c11c0483cb898 to your computer and use it in GitHub Desktop.
functions
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 | |
/** | |
* Curl init function | |
* @param (string)$url | |
* @param (array)$params | |
* @return $response | |
*/ | |
function curlInit($url = '', $params = array()) | |
{ | |
$c = curl_init($url);//.json | |
curl_setopt($c, CURLOPT_RETURNTRANSFER, true); | |
//curl_setopt($c, CURLOPT_POST, true); | |
curl_setopt($c, CURLOPT_HEADER, false); | |
// curl_setopt($c, CURLOPT_POSTFIELDS, http_build_query($params)); | |
curl_setopt($c, CURLOPT_SSL_VERIFYHOST, FALSE); | |
curl_setopt($c, CURLOPT_SSL_VERIFYPEER, FALSE); | |
//$response = json_decode($response, true);//if response json | |
$response = curl_exec($c); | |
// $response['errors'][] = curl_error($c); | |
return $response; | |
} |
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 | |
/** | |
* Pretty dump any data | |
* | |
* @param $variable | |
* @param $string | |
* | |
* @return $string | |
*/ | |
function dump($variable, $string = 'DEBUG::') | |
{ | |
echo date("Y-m-d H:i:s") . ' : <br/>'; | |
echo $string . ' : <br/><pre>'; | |
var_dump($variable); | |
echo '</pre>'; | |
exit(); | |
} |
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 | |
/** | |
* PDO Mysql conn | |
* | |
* @param $close | |
* | |
* @return (object)$connection | |
*/ | |
function db($close = false) | |
{ | |
$host = "localhost"; | |
$db_name = " "; | |
$login = " "; | |
$password = " "; | |
$connection = new PDO('mysql:host=' . $host . ';dbname=' . $db_name, $login, $password, array( | |
// PDO::ATTR_PERSISTENT => true | |
PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8" | |
)); | |
if ($close) { | |
$connection = null; | |
} | |
return $connection; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment