update
This commit is contained in:
45
src/inc/common.php
Normal file
45
src/inc/common.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
function debug_var($input) {
|
||||
@ob_start();
|
||||
print_r($input);
|
||||
$content = ob_get_contents();
|
||||
@ob_end_clean();
|
||||
|
||||
echo join("\r", ['<textarea cols="80" rows="20">', $content, '</textarea>']) ;
|
||||
}
|
||||
|
||||
function init_autoload(){
|
||||
$classLoader = require_once ROOT_DIR . '/package/vendor/autoload.php';
|
||||
$classLoader->add("Hura", ROOT_DIR . '/src' );
|
||||
|
||||
return $classLoader;
|
||||
}
|
||||
|
||||
//get current paging id
|
||||
function getPageId(){
|
||||
return getRequestInt('page', 1);
|
||||
}
|
||||
|
||||
function getPageSize($default=10){
|
||||
return getRequestInt('pageSize', $default);
|
||||
}
|
||||
|
||||
//Function to get the post value in submit
|
||||
function getPost($var, $default="", $encode = false, $keep_tag=""){
|
||||
return isset($_POST[$var]) ? $_POST[$var] : $default;
|
||||
}
|
||||
|
||||
//Function to get the INTERGER request value of a variable
|
||||
function getRequestInt($var, $min_value = 0){
|
||||
$request = isset($_REQUEST[$var]) ? (int) $_REQUEST[$var] : (int) $min_value;
|
||||
$request = ($request >= $min_value ) ? $request : $min_value; //if user tampers request parameter
|
||||
return $request;
|
||||
}
|
||||
|
||||
|
||||
//Function to get the request value of a variable
|
||||
function getRequest($var, $default=""){
|
||||
return $_REQUEST[$var] ?? $default;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user