ScriptCult :: Code, News, Q&A for Web Developers

More »

Comments

Posted in: display errors (override ini settings if neccessary) PHP

Or do it in an .htaccess file like this:

php_flag display_startup_errors on
php_flag display_errors on
php_flag html_errors on
php_value error_reporting 32767

Posted in: Simple overlay div jQuery

This will overlay the complete page with a transparent div and is a bit shorter:

$(function() {
         $("<div id='overlay'></div>")
            .height($(document).height())
            .css({
               'opacity' : 0.4,
               'position': 'absolute',
               'top': 0,
               'left': 0,
               'background-color': 'green',
               'width': '100%',
               'z-index': 5000
            })
           .appendTo('body');
});

Posted in: detect enter key in jQuery jQuery

Since the live method has been is deprecated in jQuery, nowadays the second example would be written something like this:

$(document).on('keypress', 'form', function(e){
	if (e.keyCode == 13) {
		e.preventDefault();
		alert('hiya');
	}
});

Posted in: Leverage browser caching using PHP header() PHP

Cool, thanks!

Posted in: PHP class - ajax bridge PHP

This allows auto loading files:

header("Expires: Mon, 26 Jul 1990 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
 
if (isset($_REQUEST['m'])){
	$args = array();
	$functioncalled = $_REQUEST['m'];
 
	if (isset($_REQUEST['c'])&& ctype_alnum($_REQUEST['c'])){
		require($_REQUEST['c'].'.php'); 
		$class = ucfirst($_REQUEST['c']);
		$s = new $class ();
	}else{
		require('services.php');
		$s = new Services(); 
	}
 
	echo call_user_func_array(array($s, $functioncalled),array($_REQUEST));
}

Posted in: Wrap the form element and label seperately using the HtmlTag decorator Zend Framework

I try this in zend 1.12 but no work, what wrong.
My code :

class Application_Form_Proce extends Zend_Form
{
    public function __construct($options = null)
    {
        parent::__construct($options);
 
        $this->setName('processo')
             ->setAction('post')
             ->setAttribs(array('class'=>'form-horizontal'))
             ->removeDecorator('HtmlTag');
 
        $title2 = new Zend_Form_Element_Text('email2');
        $title2->setDecorators( array(
            'Errors',
            'ViewHelper',
            array( array( 'wrapperField' => 'HtmlTag' ), array( 'tag' => 'div', 'class' => 'input' ) ),
            array( 'Label', array( 'placement' => 'prepend' ) ),
            array( array( 'wrapperAll' => 'HtmlTag' ), array( 'tag' => 'div', 'class' => 'clearfix' ) ),
        ) );
 
 
 
        $this->addElements(array ( $title2));
 
    }
}
Tks

Posted in: Check if string is alphanumeric (plus underscore and dot) with preg_match PHP

nice..............

Posted in: Regular Expressions tutorial Python

'Regular expressions in Python and Perl' is also very good :

http://www.johndcook.com/python_regex.html

rendered @ Thu May 23 1:17:55 CEST 2013