my code stock.com

Main class loader

Snippet options

Download: Download snippet as wellartphp.php.
Copy snippet: For this you need a free my code stock.com account.
Embed code : You will find the embed code for this snippet at the end of the page, if you want to embed it into a website or a blog!

<?php
define("URL_BASE","localhost/sierraNegra/");
define("DB_HOST","localhost");
define("DB_USER","root");
define("DB_PASS","");
define("DB_NAME","sierra_negra");

function curPageURL() {
 $pageURL = "";
 if ($_SERVER["SERVER_PORT"] != "80") {
  $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
 } else {
  $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
 }
 return $pageURL;
}

class cnx{
	var $cnx;

	function __construct(){
		$this->cnx = new mysqli(DB_HOST,DB_USER,DB_PASS,DB_NAME);
		return $this->cnx;
	}
    
    //funcion para escapar los campos antes de incluírlos en consultas sql
	function escapar($str){
		$str = filter_var($str,FILTER_SANITIZE_FULL_SPECIAL_CHARS);
		return $this->cnx->real_escape_string($str);
	}

	//regresa false en caso de no ser un string o tener longitud igual a cero.
	//regresa el numero espacios en blanco en caso de contener.
	function blankSpaces($str){
		if(is_string($str)){
			if(strlen($str) > 0){
				$count = substr_count($str," ");
				return $count;
			}
		}
		return false;
	}
    
    //regresa true si un string tiene valor o false si está vacío.
	function hasVal($str){
		if(strlen($str) === 0){ return false; }
		if(!isset($str)){ return false;}
		return true;
	}
}

//aquí se van a ir incluyendo las demás clases
include("class/dataUser.php");
?>

Create a free my code stock.com account now.

my code stok.com is a free service, which allows you to save and manage code snippes of any kind and programming language. We provide many advantages for your daily work with code-snippets, also for your teamwork. Give it a try!

Find out more and register now

You can customize the height of iFrame-Codes as needed! You can find more infos in our API Reference for iframe Embeds.