20 February 2008

Speed Up Internet Explorer (IE) Hack

even if IE is not preferred browser today, in fact some of the windows user still using this browser, below is the way to speed up the IE
This is a compilation for the legendary Internet Explorer.. which is the most frequently used browser .

internet Exporer Tricks: Rahul

INTERNET EXPLORER Speed up STARTUP .



I
sn't it annoying when you want to go to a new website, or any other site but your homepage, and you have to wait for your 'home' to load? This tweak tells Internet Explorer to simply 'run', without loading any webpages. (If you use a 'blank' page, that is still a page, and slows access. Notice the 'about:blank' in the address bar. The blank html page must still be loaded..). To load IE with 'nothing' [nothing is different than blank]:

1. Right-click on any shortcut you have to IE
[You should create a shortcut out of your desktop IE icon, and delete the original icon]
2. Click Properties
3. Add ' -nohome' [with a space before the dash] after the endquotes in the Target field.
4. Click OK
Fire up IE from your modified shortcut, and be amazed by how fast you are able to use IE!

~ cheers ~ (it works)


INTERNET EXPLORER SPEED UP.



Edit your link to start Internet Explorer to have -nohome after it. For Example: "C:\Program Files\Internet Explorer\IEXPLORE.EXE" -nohome
This will load internet explorer very fast because it does not load a webpage while it is loading. If you want to go to your homepage after it is loaded, just click on the home button.


or


Open registry editor by going to Start then >> Run and entering >> regedit.

Once in registry, navigate to key.

HKEY_CURRENT_USER\Software\microsoft\Windows\CurrentVersion\InternetSettings. Right click @ windows right > New > DWORD.

Type MaxConnectionsPerServer > You can set value (the more higher the no, the more good speed u get, e;g : 99). [99 in hexa so 153 in binary]

Create another DWORD >type MaxConnectionsPer1_0Server. Then put a high value as mentioned above.

Restart I.E and you are done.


SPEED UP BROWSING WITH DNS trick.!!



when you connect to a web site your computer sends information back and forth, this is obvious. Some of this information deals with resolving the site name to an IP address, the stuff that tcp/ip really deals with, not words. This is DNS information and is used so that you will not need to ask for the site location each and every time you visit the site. Although WinXP and win2000 has a pretty efficient DNS cache, you can increase its overall performance by increasing its size. You can do this with the registry entries below:



Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Dnscache\Parameters]
"CacheHashTableBucketSize"=dword:00000001
"CacheHashTableSize"=dword:00000180
"MaxCacheEntryTtlLimit"=dword:0000fa00
"MaxSOACacheEntryTtlLimit"=dword:0000012d



make a new text file and rename it to dnscache.reg. Then copy and paste the above into it and save it. Then merge it into the registry.


START Internet EXPLORER WITH EMPTY BLUE SCREEN.!!



Set your default page to about:mozilla and IE will show a nice blue screen upon startup.


FIX IE 6 SLOWDOWNS AND HANGS.



1. Open a command prompt window on the desktop (Start/Run/command).
2. Exit IE and Windows Explorer (iexplore.exe and explorer.exe, respectively, in Task Manager, i.e - Ctrl-Alt-Del/Task Manager/Processes/End Process for each).
3. Use the following command exactly from your command prompt window to delete the corrupt file:
C:\>del "%systemdrive%\Documents and Settings\%username%\Local
Settings\Temporary Internet Files\Content.IE5\index.dat"
4. Restart Windows Explorer with Task Manager (Ctrl-Alt-Del/Task Manager/Applications/New Task/Browse/C:\Windows\explorer.exe[or your path]) or Shutdown/Restart the computer from Task Manager.


SPEED UP WEB BROWSING.



Iv'e personally found a dramatic increase in web browsing after clearing the Windows XP DNS cache. To clear it type the following in a command prompt: ipconfig /flushdns.

ALLOW MORE THAN 2 SIMULTANEOUS DOWNLOADS ON IEXPLORER 6.
This is to increase the the number of max downloads to 10.
1. Start Registry Editor (Regedt32.exe).
2. Locate the following key in the registry:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings
3. On the Edit menu, click Add Value , and then add the following registry values:
"MaxConnectionsPer1_0Server"=Dword:0000000a
"MaxConnectionsPerServer"=Dword:0000000a
4. Quit Registry Editor.


IPV6 INSTALLATION FOR WINDOWS XP.



This protocol is distined to replace the Internet Protocal Version 4 used by Internet Explorer it uses hexadecimal ip addresses instead of decimal example (decimal ip 62.98.231.67) (hexadecimal IP 2001:6b8:0:400::70c)
To install To install the IPv6 Protocol for Windows XP:
Log on to the computer running Windows XP with a user account that has local administrator privileges. Open a command prompt. From the Windows XP desktop, click Start, point to Programs, point to Accessories, and then click Command Prompt. At the command prompt, type: ipv6 install
For more information on IPv6, visit the site below:
CODEhttp://www.microsoft.com/windowsxp/pro/techinfo/administration/ipv6/default.asp


ANOTHER WAY TO FIX IEXPLORER 6 SLOW PAGES LOADED.



Here's an easier way to get to index.dat file as addresse in another tweak submitted here.
1. click on Internet Explorer
2. go to to your root dir (usually C:)
3. open Documents and Settings folder
4. open "your username folder"
5. open UserData
6. **close IE if you have it open**
rename index.dat to index.old
logoff and log back on (don't need to restart) open up IE and go to a web page or site that always seemed to load slowly. It should load a lot more quickly now. NOTE. Always rename or backup .dat or other system files before deleting.

Disable Right Click!!


[HKEY_CURRENT_USER\Software\Policies\Microsoft\Internet Explorer\Restrictions]
"NoBrowserContextMenu"=dword:00000001

Enable Right Click!!


[HKEY_CURRENT_USER\Software\Policies\Microsoft\Internet Explorer\Restrictions]
"NoBrowserContextMenu"=dword:00000000


do u want to save entire Page For offline viweing??


Saving Web Pages with Internet Explorer 6

Occasionally, you may want to save an entire Web page on your computer (text, hyperlinks, graphics, and all). To save the Web page that currently appears in Internet Explorer, choose File-->Save As to open the Save Web Page dialog box shown in the following figure. Select the folder in which you want the page saved and then click the Save button.
After saving a Web page on your hard drive, you can open it in Internet Explorer and view the contents even when you're not connected to the Internet. If your motive for saving the Web page, however, is to be able to view the content when you're not connected to the Internet, you're better off saving the page as a Favorite marked for offline viewing. That way, you can decide whether you want to view other pages linked to the one you're saving and you can have Internet Explorer check the site for updated content.
You can also e-mail a Web page or a link to the page to a colleague or friend. To send the current Web page in a new e-mail message, click File-->Send-->Page by E-mail on the Explorer menu bar and then fill out the new e-mail. To send a link to the page instead, click File-->Send-->Link by E-Mail. To create a desktop shortcut to the Web page, click File-->Send-->Shortcut to Desktop.


~ all of them are tested ! ~


Alternate trick


Before performing these steps you need to test your broadband speed
you can test your speed at http://www.2wire.com/
The broadband connection speed can be increased by clearing the route from modem to server. Number of packets sent by modem to server should be increased.Internet speed can be increased by increasing more number of incoming and outgoing packets.The main reason why your internet connection is slow is because of harmful virus.If your system is infected with virus your number of incomming packets will be decreased.This leads to your slower internet speed.Internet speed can be increased by by clearing the route to the server.
This can be done by upgrading costly sofwares and hardwares.This will optimize your system speed.And Increase your system speed.Internet tweak is the best software which increases your system speed for further applications.Another software Windows power tools which makes windows faster and increases your internet speed.And decreases downloading time.It optimizes LAN,CABLE,DSN etc.Another software "internet cyclone"which increases your internet speed from 64kbps to 120kbps.
This tip is designed for increased BROADBAND speed in Windows XP while using standard Network Interface cards (NIC) that are connected to ADSL modems, or when using any directly-connected USB ADSL modem.

To speed up the Internet connection speed we need to configure a special buffer in the computer's memory in order to enable it to better deal with interrupts made from the NIC or the USB modem.

This tip is only recommended if you have 256MB RAM or higher.

Step #1 - Identify the IRQ used by the NIC/USB modem

1. Open the System Information tool by running MSINFO32.EXE from the Run command.

2. Expand System Summary > Hardware Resources > IRQs.

3. Look for the listing made for your NIC (in my case - a Intel® PRO/100+ Management Adapter). Note the IRQ next to the specified line (in my case - IRQ21).

In case of USB modems you will first need to find the right USB device used by your modem. Follow these steps:

1. Open the Device Manager tool by running DEVMGMT.MSC from the Run command (or by right-clicking My Computer > Hardware tab > Device Manager button).

2. Scroll down to Universal Serial Bus controllers and expand it.

3. Right-click the USB Root Hub and select Properties. Note that you might need to do so for all listed USB Root hubs (if there are more than one) in order to find the right one.

4. In the Power tab, look for your USB ADSL modem.

5. In the Resources tab look for the assigned IRQ (in this case - IRQ21).

6. This is the IRQ we're looking for.

Note: IRQs and modem names might vary...

Step #2 - Modify the system.ini file

1. Run SYSEDIT.EXE from the Run command.

2. Expand the system.ini file window.

3. Scroll down almost to the end of the file till you find a line called [386enh].

4. Press Enter to make one blank line, and in that line type IRQX=4096 where X is the designated IRQ number we found in step #1, in my case it's IRQ21.

Note: This line IS CASE SENSITIVE!!!

5. Click on the File menu, then choose Save.

6. Close SYSEDIT and reboot your computer.

Done. Speed improvement will be noticed after the computer reboots.

by rahuldut1
Readmore »»

19 February 2008

5 FAQs To Show You How To Choose A Good Domain Name

Registering a domain name for the first time? I assume you have many questions in your mind. In this article, let us go through 5 FAQ on how to choose a good domain name.

1) What domain name should I choose?

You should choose a domain name that is meaningful. For example, if you are going to build an information site about gorilla, naturally, you should register “allaboutgorilla.info” instead of “allaboutmonkeys.info”.

However, if you are building an information website about different types of monkeys, the “allaboutmonkeys.info” is preferred. In fact, when you are writing about gorilla, you can simply name the page as “allaboutmonkeys.info\gorilla.html”.

2) Should I choose a long or short domain name?

Generally, a shorter domain name is preferred over a long domain name because it is usually easier for people to remember. For example, if you are selling mobile phones, you will want to register “newmobilephones.com” instead of “averygoodnewandcheapmobilephone.com”.

Of course, there are always exceptions. For example, if you are selling rackets, you will want to register “topqualityrackets.com” instead of “tqr.com”. In this example, the former domain name is definitely more memorable.

3) Is there any legal issues that I should be aware of?

That is a very good question. There are certain terms that are trademarks. You should not try to register them. For example, you should try to avoid domain name like “delll.com”. If you are unsure, consult a professional who is qualified to give you legal advice.

4) Should I use hyphen in my domain name?

I would advise you not to use hyphen if you can avoid it. Why? Well, let us consider “ilovecoffee.com” and “i_love_coffee.com”. Generally, when people are searching for a domain name, they will usually type in the domain name without the hyphen first. Therefore, instead of visiting your site, they may end up in your competitor site instead.

However, if your desired domain name is already registered, then you may have to use the hyphened version instead. Alternatively, you may want to approach the owner to see if it is available for sale. You may be able to get it for a good price. Who know?

5) Should I register a “.com”, “.net” or “.info”?

In most situations, a “.com” is the best choice because when people are searching for a domain name, they will usually try “.com” first. This is normal as “.com” is a popular extension.

However, there are always exceptions. For example, if you are registering a site for an education institution, naturally, you will want to register “.edu” instead of “.com”. That is because in this scenario, when people are searching for educational site, they will search for “.edu” first instead of “.com”.


Lubano Lim is a Netpreneur who enjoys marketing on the Internet.

Looking for home based internet business opportunities? For a very limited time, discover the secret system used by many ordinary people to attract thousands of targeted prospects without any cold calling.

Visit http://kingofsponsoring.com now for a free 7 days Boot Camp.

This article is free for republishing
Source: http://www.a1articles.com/article_472564_1.html
Readmore »»

Getting Started With A Cheap Web Site Design And Hosting Service

The exhilaration level of signing up with a cheap web site design and hosting service and seeing a personal domain name come back as approved can be incredibly high. Business owners and individuals alike often feel a sense of euphoria when they realize their own site is about to go onto the World Wide Web. Unfortunately, this sense of amazement often turns to feelings of dread as newcomers to the web site design and operating field have no idea what to do next.

The fact of the matter is that domain name selection and registration is only the first part of the process of getting a web site online. If a cheap web site design and hosting company has been selected to handle the site, chances are would be site operators are sitting on a goldmine of tools that can help them take the next steps in relative stride. Make no mistake though – web site creation and publishing is serious business.
This is especially so if a person hopes to generate income from a site. What happens after the registration can make or break the effort.

Cheap web site design and hosting deals have to be taken to the next level for anything to happen. This means site name owners need to follow a basic process to create their sites, load them with content and publish them to the web. Until this is done, a domain name is nothing more than a letters on a page. To get the ball rolling, it helps for site owners to:

  • Carefully consider their focus. If making money off a web site is the real desire, focus should very likely be rather targeted. This can help with content development and keyword selection. If, for example, the site will be dedicated to affiliate programs, select with care. Joining a program that sells chocolate and one that sells video games can result in site content that makes no sense. Joining a chocolate affiliate program and a gourmet dessert delivery company's affiliate program can work very well together. Do sit down and brainstorm focus, desired content and even looks before moving forward. These decisions will help determine how best to proceed with the actual site construction. Cheap web site design and hosting deals can make participating in affiliate programs very rewarding, but the ultimate success depends on the site owner's ability to focus and market a site.


  • Site construction. Once the focus for the site has been decided upon, the next steps in launching a cheap web site design and hosting domain are generally the most fun and tedious all at the same time. It is here where the site will need to be constructed. Use provided web site building tools if possible or even templates. Just keep the focus of the site in mind. A background of tire treads and neat trucks, for example, doesn't lend itself to a site dedicated to chocolate. If there are concerns about abilities to alter templates or follow site building programs, consider hiring a pro for maximum ease. This will cost some serious money, but it can pay off with a well designed site.


  • Content creation.It doesn't matter whether a site is dedicated to chocolate or writing about current news events, content needs to go into place before the final launch. When using cheap web site design and hosting tools and templates, remember that keyword rich content that is relevant can drive traffic to a site. Some site owners write their own content, but others hire pros to do it for them. If the traffic and sales come, this investment is well worth the money. Do put some content in place prior to the launch, but plan on adding updates on a regular basis. This can keep a site looking and feeling fresh.


  • Launching. Once content is in place and the site is completely built, it's time to launch. Most cheap web site design and hosting offers make this very easy for clients to do. Just follow the instructions and the domain name used will very shortly have its own web site attached to it.

Author: This Article wrote by our team of experts and unique propery of Hosting-Review-Center (http://www.hosting-review-center.com).
Hosting-Review-Center ranks and review the best rated web hosting providers, windows and dedicated server hosting. Top 10 web hosting companies, small business web host, web host rating, web hosting articles and more.


This article is free for republishing
Source: http://www.a1articles.com/article_473352_2.html
Readmore »»

Fundamentals of ASP.Net programming vs. PHP programming


In this day’s websites normally requires simple web hosting plans for smooth performance of the website and email transfer that is essential. There are two modes of hosting planes are generally available, first is Linux hosting and second one is Windows hosting. Both have several advantages and disadvantages respectively but Depending upon small business owner’s requirements suitable managed hosting plan can be selected for a specific website.

Well in most of the normal situations, the general preference of small business owners for choosing web hosting plan moves towards the Linux server hosting plans rather than window server hosting, because there are numerous optimistic factor that influence people to choose it.

Expenditure Factor

The truth is that Linux hosting plans are much economical than Windows servers plans. For all small business people the web hosting price matters vastly. They wish to receive many options or you can say facilities at a tiny expenditure. Most of them not required supreme type of security and they also do not bother whether it is MS-SQL database server or some thing else to develop their database. Thus Linux server is the best option for them at really least cost with several kinds of features.

Open Source Factor

Linux is an Open Source code and enables people from all around the world to promote their own knowledge for its development. This is one of the main reasons where Linux servers have the power to eject Windows servers far away form competitive hosting industry. Now a day’s, due to its farthest adaptability Linux becomes a unique platform for lots of fresh technologies that are mostly used in competitive hosting industry. This means that a Linux server gives you numerous features than Windows servers can does.

Scripting Language Factor

There are many scripting language available on the Internet like Perl, Python, Java, and PHP to build your site. All these scripting languages and have been developed on Linux / UNIX web servers and they do not required Microsoft support to run them. But when you use those scripting languages which can be run on windows servers like ASP.Net then you require MS-SQL to develop the database and other supports of Microsoft. Now it is easily understandable that for small business owners Linux hosting is best to host their website into the internet.

Dependability Factor

Now a day’s Linux is vastly known as really steady and dependable. This means that Linux servers are little faster, easy to use and reputed as non crushable than a Windows server. Thus, Linux servers will provide more upgraded facilities for your website at a minimum outlay.

Familiarity and Executing Speed Factor

Linux servers have years of experience for providing services than Windows servers in hosting industry. There is no such recommendable difference in executing speed between Linux servers and Windows servers, but it is viewed that Linux servers are slightly quicker in processing normal website pages.

Efficiency Factor

Windows support ASP which is a programming language supported by Microsoft, which allows people to fabricate dynamic database motivated website pages by connecting with a MS-SQL server or Access server. It increase the production cost as well. Linux neither requires ASP language nor MS-SQL databases to build dynamic database driven website pages, because it simply uses MySQL database which is freely available.
This article is copyright
Source: http://www.a1articles.com/article_475534_2.html
Readmore »»

Learning Java Programming Language


There are many programming languages available and each of them is suitable for another program or application. There are people who have learnt only a few programming languages and who use these because that is what they know, bust most of the times software programmers will use the programming language that is required by the application they are creating. Java is one of the most frequently used programming language and writing in this language is somehow different from the usual Pascal or any C/C++ version but that does not mean that learning the java code is harder than learning Pascal or C++. Nowadays there are numerous applications written in Java and its terminology it may seem a bit harder in the beginning but anyone can write in this programming language, that's for sure.

When looking into a new programming language, most people would like to know if it is easy to learn and work in. If you compare it to C or C++, you may discover that indeed, using it can be more straight forward. This is due to the fact that Java has far fewer surprises compared to C versions. C and C++ make use of a lot of peculiarities so learning and mastering them all can be a daunting task (for example, temporary variables hang around long after the function that created them has terminated). Being more straight forward, Java is a bit easier to learn and to work with. Java eliminates explicit pointer dereferences and memory allocation/reclamation, for example, two of the most complicated sources of bugs for C and C++ programmers. Out of range subscripts are easy to find, as Java is able to do add array bounds checking. Others may argue that it seems easier to work with because there are very few examples of extremely complicated projects done using it, but the general accepted idea is that it is somehow easier to master than C or C++.

Learning Java programming is not very difficult, especially if you are familiar with other, more basic, programming languages and you know for sure what you want to create using it and it has a series of benefits compared to C and C++. First of all, code written in this programming language is portable. Code written in C and C++ is not and this makes Java more practical (for example, in C and C++, each implementation decides the precision and storage requirements for basic data types.

When you want to move from one system to another, this is a source of problems because changes in numeric precision can affect calculations). On the other hand, Java defines the size of basic types for all implementations (for example, an "int" on one system is the same size and it represents the same range of values as on every other given system). Find out more at http://www.whatiscomputerprogramming.com

The cases of programs that make use of floating point arithmetic requires a special attention: a program that uses floating point calculations can produce different answers on different systems (in this case, the degree of difference increases with the number of calculations a particular value goes through). But this is a thing specific to all floating point code, not only Java code which is also more portable then C or C++ in its object code. It compiles to an object code for a theoretical machine - in other words, the interpreter emulates that machine. This translates to the fact that code compiled on one computer will run on other computer machines that has a Java interpreter, but more on this subject you will find out while learning Java programming.


Learn more about computer programming languages including Computer Programming Training, tutorials and programming tools at => http://www.whatiscomputerprogramming.com
Readmore »»

09 February 2008

Free Hosting From 000webHost | PHP mySql free Hosting |

Free Web Hosting

Here comes the new free hosting from 000webhost.com its absolutely free host and no ads applied in the free host
the feature are
  1. 250 MB storage
  2. 100 GB transfer
  3. Php mysql support
  4. no advertising or banner embeded
  5. referal program for registered member
im already use its service and its very good for people who want a stabil freehost in the web
join now for free
click the banner for join
Free Web Hosting Readmore »»

06 February 2008

PHP Programing | PHP Basic | chapter 7 Classes and Object

class
A class is a collection of variables and functions working with these variables. A class is defined using the following syntax:
class Cart {
var $items; // Items in our shopping cart
// Add $num articles of $artnr to the cart
function add_item ($artnr, $num) {
$this->items[$artnr] += $num;
}
// Take $num articles of $artnr out of the cart
function remove_item ($artnr, $num) {
if ($this->items[$artnr] > $num) {
$this->items[$artnr] -= $num;
return true;
} else {
return false;
}
}
}
?>
This defines a class named Cart that consists of an associative array of articles in the cart and two functions to add and remove items from this cart.
Note: In PHP 4 and newer, only constant initializers for var variables are allowed. Use constructors for non-constant initializers.
/* None of these will work in PHP 4. */
class Cart {
var $todays_date = date("Y-m-d");
var $name = $firstname;
var $owner = 'Fred ' . 'Jones';
}

/* This is how it should be done. */
class Cart {
var $todays_date;
var $name;
var $owner;

function Cart() {
$this->todays_date = date("Y-m-d");
$this->name = $GLOBALS['firstname'];
/* etc. . . */
}
}
Classes are types, that is, they are blueprints for actual variables. You have to create a variable of the desired type with the new operator.
$cart = new Cart;
$cart->add_item("10", 1);
This creates an object $cart of the class Cart. The function add_item() of that object is being called to add 1 item of article number 10 to the cart.
Classes can be extensions of other classes. The extended or derived class has all variables and functions of the base class and what you add in the extended definition. This is done using the extends keyword. Multiple inheritance is not supported.
class Named_Cart extends Cart {
var $owner;
function set_owner ($name) {
$this->owner = $name;
}
}
This defines a class Named_Cart that has all variables and functions of Cart plus an additional variable $owner and an additional function set_owner(). You create a named cart the usual way and can now set and get the carts owner. You can still use normal cart functions on named carts:
$ncart = new Named_Cart; // Create a named cart
$ncart->set_owner ("kris"); // Name that cart
print $ncart->owner; // print the cart owners name
$ncart->add_item ("10", 1); // (inherited functionality from cart)
Within functions of a class the variable $this means this object. You have to use $this->something to access any variable or function named something within your current object. Both in and outside of the object you do not need a $ when accessing an object's properties.
$ncart->owner = "chris"; // no $

$ncart->$owner = "chris";
// this is invalid because $ncart->$owner = $ncart->""

$myvar = 'owner';
$ncart->$myvar = "chris";
// this is valid because $ncart->$myvar = $ncart->owner
Constructors are functions in a class that are automatically called when you create a new instance of a class. A function becomes a constructor when it has the same name as the class.
class Auto_Cart extends Cart {
function Auto_Cart () {
$this->add_item ("10", 1);
}
}
This defines a class Auto_Cart that is a Cart plus a constructor which initializes the cart with one item of article number "10" each time a new Auto_Cart is being made with "new". Constructors can also take arguments and these arguments can be optional, which makes them much more useful.
class Constructor_Cart extends Cart {
function Constructor_Cart ($item = "10", $num = 1) {
$this->add_item ($item, $num);
}
}
// Shop the same old boring stuff.
$default_cart = new Constructor_Cart;
// Shop for real...
$different_cart = new Constructor_Cart ("20", 17);
For derived classes, the constructor of the parent class is not automatically called when the derived class's constructor is called.
References inside the constructor
Creating references within the constructor can lead to confusing results. This tutorial-like section helps you to avoid problems.

class foo {
function foo($name) {
// create a reference inside the global array $globalref
global $globalref;
$globalref[] = &$this;
// set name to passed value
$this->setName($name);
// and put it out
$this->echoName();
}

function echoName() {
echo "
",$this->Name;
}
function setName($name) {
$this->Name = $name;
}
}
Let us check out if there is a difference between $bar1 which has been created using the copy = operator and $bar2 which has been created using the reference =& operator...
$bar1 = new foo('set in constructor');
$bar1->echoName();
$globalref[0]->echoName();
/* output:
set in constructor
set in constructor
set in constructor */
$bar2 =& new foo('set in constructor');
$bar2->echoName();
$globalref[1]->echoName();

/* output:
set in constructor
set in constructor
set in constructor */
Apparently there is no difference, but in fact there is a very significant one: $bar1 and $globalref[0] are _NOT_ referenced, they are NOT the same variable. This is because "new" does not return a reference by default, instead it returns a copy.
Note: There is no performance loss (since php 4 and up use reference counting) returning copies instead of references. On the contrary it is most often better to simply work with copies instead of references, because creating references takes some time where creating copies virtually takes no time (unless none of them is a large array or object and one of them gets changed and the other(s) one(s) subsequently, then it would be wise to use references to change them all concurrently).
To prove what is written above let us watch the code below.
// now we will change the name. what do you expect?
// you could expect that both $bar and $globalref[0] change their names...
$bar1->setName('set from outside');

// as mentioned before this is not the case.
$bar1->echoName();
$globalref[0]->echoName();

/* output:
set on object creation
set from outside */

// let us see what is different with $bar2 and $globalref[1]
$bar2->setName('set from outside');

// luckily they are not only equyl, they are thesame variable
// thus $bar2->Name and $globalref[1]->Name are the same too
$bar2->echoName();
$globalref[1]->echoName();

/* output:
set from outside
set from outside */
Another final example, try to understand it.

class a {
function a($i) {
$this->value = $i;
// try to figure out why we do not need a reference here
$this->b = new b($this);
}

function createRef() {
$this->c = new b($this);
}

function echoValue() {
echo "
","class ",get_class($this),': ',$this->value;
}
}


class b {

function b(&$a) {
$this->a = &$a;
}

function echoValue() {
echo "
","class ",get_class($this),': ',$this->a->value;
}

}

// try to undestand why using a simple copy here would yield
// in an undesired result in the *-marked line
$a =& new a(10);
$a->createRef();

$a->echoValue();
$a->b->echoValue();
$a->c->echoValue();

$a->value = 11;

$a->echoValue();
$a->b->echoValue(); // *
$a->c->echoValue();

/*
output:
class a: 10
class b: 10
class b: 10
class a: 11
class b: 11
class b: 11
*/

Article 8
Title : PHP Programing | PHP Basic | chapter 8 References
References are a means in PHP to access the same variable content by different names. They are not like C pointers, they are symbol table aliases. Note that in PHP, variable name and variable content are different, so the same content can have different names. The most close analogy is with Unix filenames and files - variable names are directory entries, while variable contents is the file itself. References can be thought of as hardlinking in Unix filesystem.
PHP references allow you to make two variables to refer to the same content. Meaning, when you do:
$a =& $b
it means that $a and $b point to the same variable.
Note: $a and $b are completely equal here, that's not $a is pointing to $b or vice versa, that's $a and $b pointing to the same place.
The same syntax can be used with functions, that return references, and with new operator (in PHP 4.0.4 and later):
$bar =& new fooclass();
$foo =& find_var ($bar);
Note: Unless you use the syntax above, the result of $bar = new fooclass() will not be the same variable as $this in the constructor, meaning that if you have used reference to $this in the constructor, you should use reference assignment, or you get two different objects.
The second thing references do is to pass variables by-reference. This is done by making a local variable in a function and a variable in the calling scope reference to the same content. Example:
function foo (&$var) {
$var++;
}

$a=5;
foo ($a);
will make $a to be 6. This happens because in the function foo the variable $var refers to the same content as $a
Passing by Reference
You can pass variable to function by reference, so that function could modify its arguments. The sytax is as follows:
function foo (&$var) {
$var++;
}

$a=5;
foo ($a);
// $a is 6 here
Note that there's no reference sign on function call - only on function definition. Function definition alone is enough to correctly pass the argument by reference.
Following things can be passed by reference:
· Variable, i.e. foo($a)
· New statement, i.e. foo(new foobar())
· Reference, returned from a function, i.e.:
function &bar()
{
$a = 5;
return $a;
}
foo(bar());
Any other expression should not be passed by reference, as the result is undefined. For example, the following examples of passing by reference are invalid:
function bar() // Note the missing &
{
$a = 5;
return $a;
}
foo(bar));

foo($a = 5) // Expression, not variable
foo(5) // Constant, not variable
These requirements are for PHP 4.0.4 and later.
Returning References
Returning by-reference is useful when you want to use a function to find which variable a reference should be bound to. When returning references, use this syntax:
function &find_var ($param) {
...code...
return $found_var;
}

$foo =& find_var ($bar);
$foo->x = 2;
In this example, the property of the object returned by the find_var function would be set, not the copy, as it would be without using reference syntax.
Note: Unlike parameter passing, here you have to use & in both places - to indicate that you return by-reference, not a copy as usual, and to indicate that reference binding, rather than usual assignment, should be done for $foo.
Unsetting References
When you unset the reference, you just break the binding between variable name and variable content. This does not mean that variable content will be destroyed. For example:
$a = 1;
$b =& $a;
unset ($a);
won't unset $b, just $a.
Again, it might be useful to think about this as analogous to Unix unlink call.
Spotting References
Many syntax constructs in PHP are implemented via referencing mechanisms, so everything told above about reference binding also apply to these constructs. Some constructs, like passing and returning by-reference, are mentioned above. Other constructs that use references are:
global References
When you declare variable as global $var you are in fact creating reference to a global variable. That means, this is the same as:
$var =& $GLOBALS["var"];
That means, for example, that unsetting $var won't unset global variable.
$this
In an object method, $this is always reference to the caller object.
This is the last chapter I write about PHP but it doesn’t mean that PHP only until this subject because there much more about PHP.and in my article is very litle part from the Big Part of PHP. Next time I will discused about PHP again with more advanced chapter about PHP. Thanks to all my friend for the help writing this article. Readmore »»

Blog Archive

get update

 Subscribe in a reader

Enter your email address:

Delivered by FeedBurner