To get a html page to display UTF-8 encoded text correctly (without setting a default charset) simply add the following to the head of the html page.
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
To get a html page to display UTF-8 encoded text correctly (without setting a default charset) simply add the following to the head of the html page.
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
The first idea that comes into mind for doing this is to simply make a typecast of the boolean variable to a string and use that (which works)
$testVar = false; echo (string)$testVar; //will output a empty string (as that evaluates to false) $testVar = true; echo (string)$testVar; //will output 1 (as that evaluates to true)
but what if the requirement is that the string should say true or false
$testVar = false; echo $testVar ? 'true' : 'false'; //will output false $testVar = true; echo $testVar ? 'true' : 'false'; //will output true
(While the above example might seam useless I recently had to do this for a db insert)
Windows, Linux/Unix and Mac have different line-endings on text files.
A quick overview on the endings are:
A HEX editor can be used to double check that the correct endings are written.
Static functions can be used without instantiating the object.
A quick example of a static function is shown below as well as a comparison with a non static function.
A quick example of this (in PHP5):
class TestClass{ static function staticFunction(){ echo "static function called"; } function nonStaticFunction(){ echo "nonstatic function was called"; } } TestClass::staticFunction(); //will echo static function called $testClass = new TestClass(); $testClass.nonStaticFunction(); //will echo nonstatic function was called unset($testClass);
If you are storing uuid’s are BINARY(16) in the database, then the following will turn the stored id to the “original” format.
$uuidReadable = unpack("h*",$uuid); $uuidReadable = preg_replace("/([0-9a-f]{8})([0-9a-f]{4})([0-9a-f]{4})([0-9a-f]{4})([0-9a-f]{12})/", "$1-$2-$3-$4-$5", $uuidReadable); $uuidReadable = array_merge($uuidReadable); echo "uuid is " . $uuidReadable[0];
Sometimes it is nice to know how long a scrip took to execute (or a part of a script).
This is a simple way to time a script in php.
$time_start = microtime(true); usleep(500); $time_end = microtime(true); $time = $time_end - $time_start; echo "run time was " . $time . " seconds";
Sometimes there is a need to only allow limit access to a site using a .htaccess file.
If you still wish to be able to serve Google adsense on this page then the following example is good for this (yes the allow line should be changed to suit your needs)
# Google_ads agents BrowserMatchNoCase Mediapartners-Google good_pass BrowserMatchNoCase Adsbot-Google good_pass <LIMIT GET POST> order deny,allow deny from all allow from 123.456.789 #Google ads allow from env=good_pass </LIMIT>
When using Soapclient to access a webservice the returned object will be of a stdClass Object.
If you don’t wish to access this as an object, but would find it easier to use it as an array then a quick cast solves this.
/*As an object*/ print_r($soapResult->contents); /*cast to an array*/ $soapResult = (array)$soapResult; print_r($soapResult['contents']);
These characters are the Byte Order Mark (BOM) of the Unicode Standard.
This can be solved in two ways:
:set nobomband then save the file