http://www.phpdoc.org/
Easy, Fast, and Efficient.
Just make sure your code is developed within a standard and you comment very well.
In some situations we are required to take a value that was intended to be a string and convert it to a numerical value for calculations.
In this situation we would implement a form of variable control called "Casting".
CODE:
-
//String
-
var string = "5.00";
-
-
//What would happen if we wanted to add another 5.00 to string?
-
//Well, it would append the 5.00 to the original 5.00 - Example: 5.005.00
-
//We need to Cast "string" so that we can do numerical calculations.
-
var numeric = parseFloat(string)+5.00;
-
//You can use
-
//parseFloat - number with a decimal point.
-
//parseInt - whole number.
Simple and effective.
How do you show errors for a single php script when the entire server has the enviorment variable "display_errors" set to 0?
Simple - place the below code at the top of your script.
CODE:
-
ini_set("display_errors", 1);
-
error_reporting(E_ALL);
ini_set - allows you to mess with your php.ini file.
error_reporting - sets what kind of errors you wish to show.
My current employer is in need of a very simple advertisement plugin to be created for their WordPress system - so of course I have decided to use this as an opportunity to create a custom plugin for experimental reasons.
Plugin Title: Make Me Money
Lets see if it does haha.
Please review this great example by Dav Glass:
http://blog.davglass.com/files/yui/animseq/
I am always on the lookout for a nice simple htpasswd generator and I found a pretty nice one.
http://www.htaccesstools.com/htpasswd-generator/
Enjoy!
Hey all,
So how can you read a user who just logged in with htacess?
CODE:
-
$auth_username = $_SERVER['REMOTE_USER']
Make sure you have it right by checking phpinfo().
My problem - when a user logged into my website and then went to my "blog" area (which did not require any logging in) Wordpress would removed all the sessions I had set.
Why did it do this?
If we open wp-settings.php the first few lines of code completely remove all session information (as well as other).
CODE:
-
function wp_unregister_GLOBALS() {
-
if ( !ini_get('register_globals') )
-
return;
-
-
if ( isset($_REQUEST['GLOBALS']) )
-
die('GLOBALS overwrite attempt detected');
-
-
// Variables that shouldn't be unset
-
$noUnset = array('GLOBALS', '_GET', '_POST', '_COOKIE', '_REQUEST', '_SERVER', '_ENV', '_FILES', 'table_prefix');
-
-
$input = array_merge($_GET, $_POST, $_COOKIE, $_SERVER, $_ENV, $_FILES, isset($_SESSION) && is_array($_SESSION) ? $_SESSION : array());
-
foreach ( $input as $k => $v )
-
if ( !in_array($k, $noUnset) && isset($GLOBALS[$k]) ) {
-
$GLOBALS[$k] = NULL;
-
unset($GLOBALS[$k]);
-
}
-
}
To fix this issue I did the following:
CODE:
-
function wp_unregister_GLOBALS() {
-
if ( !ini_get('register_globals') )
-
return;
-
-
if ( isset($_REQUEST['GLOBALS']) )
-
die('GLOBALS overwrite attempt detected');
-
-
// Variables that shouldn't be unset
-
$noUnset = array('GLOBALS', '_GET', '_POST', '_COOKIE', '_REQUEST', '_SERVER', '_ENV', '_FILES', 'table_prefix','_SESSION');
-
-
$input = array_merge($_GET, $_POST, $_COOKIE, $_SERVER, $_ENV, $_FILES);
-
foreach ( $input as $k => $v )
-
if ( !in_array($k, $noUnset) && isset($GLOBALS[$k]) ) {
-
$GLOBALS[$k] = NULL;
-
unset($GLOBALS[$k]);
-
}
-
}