How to start default localhost in windows

Now a days there are lots of software like XAMPP,WAMP etc that provide local server .But Do you know there is also a localhost server in your Windows PC.Yes its true.But Unfortunately bydefault it is not turned on.So if you guys wanna use defualt localhost of your windows PC then this post is for you.Lets Start

Steps for How to Turn On Localhost

  • First of All go to Control Panel >> Programs and Features
  • After That Click On Turn Windows Features on or off (on rihgt side)
    How-to-start-default-localhost-in-windows-1
  • A Dialog box will appear.Now search for Internet Information Services and click on checkbox beside it and hit OK button
    How-to-start-default-localhost-in-windows-2
  • Now sit back for some miniutes and it will ask of restart your computer.just restart your computer
  • Now type 127.0.0.1 in your browser and you can see localhost is working !!
  • To access localhost file directory, go to C://inetpub/.Here you can put your files.

Thats All Mates 🙂

Hope it will Help You and please subscribe me and like my facebook page :

and make me proud.By the way if you face any problem then let me know in comment section below

Currency conversion Using Google API in PHP

sometime we want to show the current price of foreign currency in our webiste,app or blog.For this we can use google.As You know we use google for search but google also provide Currency Converter API for converting currency to our desired currency.You can use Google’s currency converter to convert currency.If you want to use this functionality in your application then i am going to tell you “How to use google currency converter ?”.

Below is complete PHP currency converter script using Google API which have a function currencyConverter($from_Currency,$to_Currency,$amount) with three parameters. The first parameter is $from_Currency, the second is $to_Currency means the currency in which it is converted. And third parameter is $amount that will be passed for conversion.

PHP Function

Call Function

Tip : You can check currency codes HERE

Download Code

Hope it will Help You and please subscribe me and like my facebook page :

and make me proud.By the way if you face any problem then let me know in comment section below

How To Create an Stylesheet only for Internet Explorer (IE)

How To Create an Stylesheet only for Internet Explorer (IE)

if you are tired of designing issue that you face in IE then this post can help you a lot.Today i am gonna tell you how to use conditional stylesheet that only works for Internet Explorer Only.And yes we will also use IE version based Stylesheets mean you can use a stylesheet only for a specific version.Before we start you must know

why use these conditional stylesheets ?

  • You got problems, they need fixin’
  • Keeps your code hack-free and valid
  • Keeps your main stylesheet clean
  • Perfectly acceptable technique, sanctioned by Microsoft

And remember, these conditional tags don’t have to be used only for CSS. You could load JavaScript, or even use them down in the content of your site to display special IE-specific messages.

How to code

This would go in your head with all the other regular CSS link ed CSS files. The opening and closing tags should be familiar, that’s just regular ol’ HTML comments. Then between the brackets, “IF” and “IE” should be fairly obvious. The syntax to note is “!” stand for “not”, so !IE means “not IE”. gt means “greater than”, gte means “greater than or equal”, lt means “less than”, lte means “less than or equal.”

Note that IE 10 and up DO NOT support conditional comments at all.

Target ALL VERSIONS of IE

Target everything EXCEPT IE

Target IE 7 ONLY

Target IE 6 ONLY

Target IE 5 ONLY

Target IE 5.5 ONLY

Target IE 6 and LOWER

Target IE 7 and LOWER

Target IE 8 and LOWER

Target IE 6 and HIGHER

Target IE 7 and HIGHER

Target IE 8 and HIGHER

Hope it will Help You and please subscribe me and like my facebook page :

and make me proud.By the way if you face any problem then let me know in comment section below

Use .htaccess file for URL Rewriting

using .htaccess you can easily configure and redirect Apache Web Server file system. This post will explain you how to create friendly URLs, sub domain directory re-directions and many more.

Note: .htaccess file will be in hidden format, please change your folder and file settings to view this file.

How to Create a .htaccess File?

Open any text editor application and file save as with .htaccess name and enable mod_rewrite extension in php.ini file in Apache Web Server configurations.

Disable directory Listing

If you want to disable folder files listing, include following code.

use-htaccess-file-for-url-rewriting-1

Error Pages
Here error page is redirecting to error.html.

use-htaccess-file-for-url-rewriting-2

RewriteEngine On it is turn on Rewrite Rules in Apache Server. if you want to turn off, just change the value to off.

Domain Redirection

.htacces code for redirecting growwebsite.com to www.growwebsite.com

Sub Domain Redirection
Sub domain redirection mapping to folder. Here http://www.growwebsite.com is connecting to website_folder folder.

Here http://subdomain.growwebsite.com is connecting to subdomain_folder folder.

Old Domain Redirection
htaccess code for redirecting old domain(abc.com) to new domain(xyz.com).

Friendly URLs
Friendly/Pretty URLs help in search engine rankings.

Profile URL

Profile parameter allows [a-zA-Z0-9_-] these inputs. More help read Understanding Regular Expression

http://growwebsite.com/profile.php?username=officialvikas01
to
http://growwebsite.com/officialvikas01

Friends URL with Two Parameters

Here the first parameter allows [a-zA-Z0-9_-] and second parameter allows only number [0-9]
http://growwebsite.com/friends.php?username=officialvikas01&page=2
to
http://growwebsite.com/friends/officialvikas01/2

Hiding File Extension

http://www.growwebsite.com/index.html
to
http://www.growwebsite.com/index

Hope it will Help You and please subscribe me and like my facebook page :

and make me proud.By the way if you face any problem then let me know in comment section below

Tips to Optimize PHP Script for Better Performance

If you are a developer, it is essential for you to optimize your script early in the development process itself. Following the best practices while coding your PHP script is a good starting point to write a well optimized PHP code.

This tutorial provides few tips to optimize PHP code from a developer point of view.

Calculate Only Once

Calculate and assign the value to the variable if that value is getting used numerous time rather than calculating it again and again where it is being used.

For example, the following will degrade the performance.

The script below will perform much better.

Use JSON

Use JSON instead of XML while working with web services as there are native php function like json_encode( ) and json_decode( ) which are very fast. If you are bound to have XML form of data, then use regular expression to parse it instead of DOM manipulation.

Pass Reference to Function

Pass reference to the function if it does not affect your logic. A function manipulating the reference is faster than those manipulating the value been passed as here one more copy of the value is getting created. Especially it adds overhead when the value passed by you is a big array.

For example, let us create a function in two different way to increment by 1, each element of an array having values 0 to 99.

The function above works faster than the function below although both will produce the same result ( increment each element of the array by 1. )

Create Classes Only When its Required

Don’t create classes and method until and unless its really needed, used and reused as well.

Use Native PHP Functions

As much as possible, try to use native PHP functions rather than writing your own functions to achieve the objective. For example, you can use range( b, k) to get an array of alphabets starting from b to k in sequence, if it is only needed once in the script rather than declaring an array with these values in a function and returning it on its call.

Frequently Used Switch Cases

Keep most frequently used switch cases on the top.

Use Appropriate Str Functions

str_replace is faster than preg_replace, but strtr is faster than str_replace by a factor of 4.

Disable Debugging Messages

File operations are expensive. So, if you have written lot of custom functions to log errors and warning during your development process, make sure you remove them before you push the code to production.

Use Caching Techniques

Use cache to reduce the load of database operations as well as the script compilation. We can use memcache for the reducing database load and APC for opcode caching and intermediate code optimization.

Close the Connection

Get into the habit to unset the variables and close database connection in your PHP code. It saves memory.

Reduce Number of Hits to DB

Try to reduce the number of hits to the database. Make queries aggregate so that you call the database less number of times. For example:

The script above is much slower than the script below:

Use Single Quotes

Using single quotes ( ‘ ‘ ) is faster than using double quotes( ” ” ) if you are going to keep only the string inside it avoiding any variables. Double quotes checks for the presence of variable and adds little bit of overhead.

Use = = =

Use “= = =” instead of “= =”, as the former strictly checks for a closed range which makes it faster.

Use Methods in Derived Classes

Methods in derived classes are faster than base classes. For example, let there be a function in both base class and derived class for performing task1. It is named as “forTask1” in base class and “forTask1again” in derived class, so that they will not override.

Call to the function forTask1again( ) which is in derived class will work faster than call to the function forTask1( ) as it is from base class.

Use isset

Use isset( ) where ever possible instead of using count( ), strlen( ), sizeof( ) to check whether the value returned is greater than 0.

For example, let us assume that you have a function which returns an array with values or a NULL array. Now you want to check whether the returned array is with values or not, then use the following:

In this case, use the above code block, instead of the following:

Hope it will Help You and please subscribe me and like my facebook page :

and make me proud.By the way if you face any problem then let me know in comment section below