When you feel you may want to use the requested url with all the get variables passed (just the way it is in the browser’s address bar), you can use the following code snippet:
private function getCurPageURL() { $pageURL = 'http'; if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";} $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; }
![]()
With global economic meltdowns & fluctuating prices, we often can’t rely on human entry to get up to date currency rates in our web applications. Especially if you are building a website which may require your products cost to be displayed in various currencies.
This is a very powerful and light weight PHP class that lets you convert between 65+ currencies using Google Finance (http://www.google.com/finance/converter)
Example:
CurrencyRates::Convert('USD', 'INR');
Output:
49 //Since $1 is Rs. 49
Sometimes you may want to display some part of the page/code only to IE users. Especially when you may be using some png fix javascript files or the famous iepngfix.htc for IE6 clients. This php function lets you identify an IE browser loading your page:
Example:
<?php if(detect_ie()) { //if internet explorer 6 being used, then apply IE png fix ?> <!--Begin IE PNG Fix--> <style type="text/css"> #shadow_tp, #shadow_btm { behavior: url(iepngfix.htc) } </style> <!--End IE PNG Fix--> <?php } ?>
Ever wanted to quickly test out a php function or a snippet of code without actually creating a new .php file & running it on a web server? In this article we are going to discuss how to display the output of some php code and display it in a mini command window using some basic batch files.
Preview:
EasyDatabase is a custom class which I developed to manage and save application settings in your j2me applications instead of dealing with sometimes confusing methods of the javax.microedition.rms. It is a wrapper class around the RMS methods provided by MIDP 2.0.
It is very easy and efficient to use and requires no knowledge about MIDP Record Management System. It more or less works like how you store values in the windows registry(if you come from a windows background). Every value has a unique property name associated with it. For e.g AppVersion, LoginPassword, StudentsName, etc..
The code below demonstrates how to create a database called “UserInfo”. First we add the users “Name” & “Age”. Then, we retreive it and print it in the console.
EasyDatabase myDB = new EasyDatabase("UserInfo"); if(myDB.dBExists() == false) { myDB.createDB(); //creates the db myDB.addProperty("Name", "Dayson"); //adds name myDB.addProperty("Age", "20"); //adds age } myDB.updateProperty("Age", "25", false); //changes age System.err.println( myDB.getProperty("Name") ); //prints name System.err.println( myDB.getProperty("Age") ); //prints age