Web Hosting Blog

Web Hosting - Network Blog

  • Home
  • About
  • Advertising
  • Contact
  • Sitemap

E-commerce Web Hosting

Posted by admin on Saturday, September 13th 2008   

Digg it

Bookmark it

Stumble it

Email to friend

13
Sep

When it comes to online store and e-commerce hosting application choosing a new Web hosting service is a big challenge. You may well be tempted to rush through this step because you are in such a hurry to move your site. However, you should take the time to choose the right provider or you will just end up with more problems in the future.

Reliability and credibility. Some of the most important things to ensure when choosing ecommerce hosting options are security, speed, space, email services, and uptime while at the same time you have to consider well about the the security features of your ecommerce hosting solution which are paramount to building trusting relationships with your customers and making them comfortable ordering from you or sharing their personal information with you over the internet. Secure servers and encryption capabilities will improve your customers’ perception and their confidence in your company.

E-commerce_Hosting

A good ecommerce web hosting provider supports a tough and reliable system that is relatively available during off peak hours, and offers 24 hours technical support. A reliable ecommerce hosting provider offers its clients reliable financial support, puts forward default-shopping carts, offers secure servers, and processes credit card payments. The secured servers ensure that the customer’s personal information and relative credit card data are handled privately. It offers comprehensive customer support.

Author : Shahram Azin

Popularity: 71% [?]

Filed under: Web Hosting     Tags: E-Commerce+Web+Hosting
No Comment Yet   

VPS Media - My New Hosting Provider

Posted by admin on Friday, September 5th 2008   

Digg it

Bookmark it

Stumble it

Email to friend

5
Sep

Blogger Buster is primarily hosted by Blogger, and uses the custom domain feature for my dot com URL. However, all of the background images, scripts, Blogger templates and other downloadable content are hosted externally, since these cannot be hosted by Blogger.

For me, reliability is of chief concern for Blogger Buster: I offer free templates; have more eBooks in progress, and am working on an integrated forum to accompany the site. I wasn’t sure that my shared hosting package could handle it, and am certainly not in the position to purchase a dedicated hosting package just yet! So when VPS Media contacted me about their Virtual Private Server packages, I couldn’t wait to give it a try!

What is a VPS?
A VPS is the link between shared and dedicated hosting: it is an isolated partition on a server and each partition the appearance and capabilities of running on its own dedicated machine. In effect, it’s like having a dedicated server, without the huge price tag!

Until recently, I was content to use a shared hosting solution. Shared hosting means that many hosting accounts are present on the same server (and often share the same IP address too); this is the cheapest form of web hosting (often free), though it does have limitations and issues of reliability.

media

My new hosting provider, VPS Media, provides blazing fast Xen VPS servers and guarantee 100% network uptime, so I know reliability is not an issue with this company! What’s more, I have complete control of my VPS: this means I can run any applications required; install my own mail server, and can use my VPS to host multiple websites too.

What I’m using now
 At present, I’m using the VPS starter package, which offers 384 MB of dedicated RAM, 15GB of data storage and 150GB of data transfer which costs $20 per month. There are no set-up fees and no contracts either. While this is slightly more than I previously paid for shared hosting, I’m more than happy to pay this for reliability and the fantastic support I’ve received surpasses that of any other hosting company I’ve used.

A VPS offers a much better standard of web hosting than a shared hosting package; however, this comes with a great degree of responsibility and the requirement of technical knowledge.

A VPS package is installed with only the bare minimum required to make it operational: it doesn’t already have a web-server, email, PHP or database packages, so in order to be able to use my VPS for web hosting, I needed to learn how to install these myself.

Considering that I had no previous experience of using Unix operating systems, I must say that this was a steep learning curve for me! Thankfully, VPS Media has a VPS article library available so customers can learn how to install various packages and use their VPS effectively. Carlos Taborda also kindly pointed me towards some highly useful articles over at How to Forge where I learned about the best set-up for my Debian operating system and other useful insights.

How my VPS will help improve Blogger Buster
As I mentioned earlier, I found my existing shared hosting package to be unreliable at times. Blogger Buster readers may have noticed slow loading times, missing images from the template, or that templates (and other downloads) are temporarily unavailable (for which my host was unable to offer any explanation!).

Now that I am hosting with VPS Media, I know that my web hosting is completely under my control. The 100% uptime guarantee assures me that my server will always be accessible, and if something goes wrong, I will be able to discover the problem and deal with this myself.
New features are on their way!
With these assurances, I feel confident in making some dramatic changes to Blogger Buster. In the next week (or so) this site will undergo a complete redesign, including the new Blogger Buster forum and the release of a new (and rather large) eBook.

I’m also in the process of transferring all my images, scripts and downloadable content over to my VPS which should result in faster page loading and that downloads will be available at all times. And since I can host multiple websites on my VPS, I’m also considering starting a new blog…

Popularity: 74% [?]

Filed under: VPS Hosting     Tags: VPS+Media
No Comment Yet   

Suhosin Install Guide

Posted by admin on Friday, September 5th 2008   

Digg it

Bookmark it

Stumble it

Email to friend

5
Sep

Suhosin is the big brother to the Hardened-PHP patch which adds an extra level of protection to PHP.  Installing Suhosin can be a bit confusing so we’ll show you how it can be easily installed on Linux.
http://www.hardened-php.net/suhosin.127.html
What is Suhosin?

There are 2 separate versions on Suhosin. You can run both together or one separately.

1) A raw patch where you need to recompile PHP in shell to work. This adds low level protection against things like buffer overflows and format string vulnerabilities.

2) A PHP extension that protects at runtime, easy to install.

Both versions will still you allow you to use other PHP extensions like Zend Optimizer without any issues.

See the full features list comparision here: http://www.hardened-php.net/suhosin/a_feature_list.html

This guide we’ll show you how to install the Extension ONLY. Recompiling PHP for the patch is a whole guide in itself, so I only recommend that for experienced users or having someone do it for you like a server admin company such as ServerProgress - www.serverprogress.com or click on Hire an Expert.

Installing Suhosin

Things to do before getting started and questions you probably have.

1) First off you need to create a phpinfo page on your web server, this is so you can see if Suhosin is installed and working or not.

EG: http://mysite.com/phpinfo.php
phpinfo();

That’s all it should contain. You should bring it up to make sure it works.

2) Check to make sure that PHP is NOT compiled with –enable-versioning

You will see this in the Configure Command section at the top, make sure you do not see

–enable-versioning
If it is, the extension will not work. Versioning breaks extensions. You will need to recompile PHP and make sure versioning is turned OFF.

3) This only applies if you are using Zend Optimizer. Make sure you are using at least version 3.2.1 or above of Zend Optimizer. If you are using anything below that there is a known bug in Zend Optimizer that gets caught up in Suhosin while reading zend encoded pages. So be sure to upgrade Optimizer to a more recent release before you install Suhosin to avoid issues.

You can check your version while in shell by doing:

php –v

If you have it installed you’ll see something like:

Zend Engine v1.3.0, Copyright (c) 1998-2004 Zend Technologies

    with Zend Extension Manager v1.0.10, Copyright (c) 2003-2006, by Zend Technologies

    with Zend Optimizer v3.0.1, Copyright (c) 1998-2006, by Zend Technologies

So this version is old and needs to be upgraded. See http://www.webhostgear.com/184.html  our Zend Optimizer install guide for more details.

Suhosin works fine on cPanel/WHM servers, DirectAdmin, Plesk and any others. As long as the above mentioned items are met then you should be fine. 

Installing Suhosin Extension

Download the source file for the Suhosin extension

cd /usr/local/wget http://www.hardened-php.net/suhosin/_media/suhosin-0.9.18.tgz

tar -zxvf suhosin-0.9.18.tgz

cd suhosin-0.9.18

phpize

OUTPUT will be something like this:

# phpize

Configuring for:

PHP Api Version:         20020918

Zend Module Api No:      20020429

Zend Extension Api No:   20050606 

./configure

make

OUTPUT will be something like this:

Libraries have been installed in:

   /usr/local/suhosin-0.9.18/modules

 

make install

OUTPUT will be something like this:

Installing shared extensions:     /usr/local/lib/php/extensions/no-debug-non-zts-20020429/

Make a note of the directory location and confirm it exists and has suhosin.so in it:

ls –lah /usr/local/lib/php/extensions/no-debug-non-zts-20020429/

-rwxr-xr-x    1 root     root         334K Mar 19 09:17 suhosin.so*

Now copy suhosin.so to /usr/lib/php/extensions since our php.ini points to that directory and not the one the make install used

cp /usr/local/lib/php/extensions/no-debug-non-zts-20020429/suhosin.so /usr/lib/php/extensions/no-debug-non-zts-20020429

Checking PHP

Now we need to check PHP to ensure suhosin will be added in. 

Find where your current PHP.ini is:

php -i |grep php.iniConfiguration File (php.ini) Path => /usr/local/Zend/etc/php.ini 

Edit the php.ini

vi /usr/local/Zend/etc/php.ini

Step 1) Ensure the include path/extension is set properly.

Search for: extension_dir

You should see something like this:

;;;;;;;;;;;;;;;;;;;;;;;;;

; Paths and Directories ;

;;;;;;;;;;;;;;;;;;;;;;;;;

include_path = “.:/usr/lib/php:/usr/local/lib/php:/usr/lib/php/extensions:/usr/lib/php/extensions/no-debug-non-zts-20020429:”   ;

extension_dir = /usr/lib/php/extensions/no-debug-non-zts-20020429/  ; directory in which the loadable extensions (modules) reside

Note the exact path is the same as what we wrote down when we did “make install”

If not, you will need to add it or COPY the file to the new location as mentioned above.

Step 2) Add the suhosin.so extension to php.ini

While still in php.ini search for Dynamic Extensions

/Dynamic Extensions 

EG you should see:
;;;;;;;;;;;;;;;;;;;;;;

; Dynamic Extensions ;

;;;;;;;;;;;;;;;;;;;;;;

Add this below: 

extension=suhosin.so

Note to 64 bit OS users:

Check to make sure php.ini is using the proper extension_dir setting:

extension_dir = /usr/lib64/php4

Then copy the suhosin.so to that directory after you do “make install”

cp -v /usr/local/lib/php/extensions/no-debug-non-zts-20020429/*.so /usr/lib64/php4/

End 64 Bit OS note:

Now save php.ini and check PHP from shell:

php -vPHP 4.4.6 (cli) (built: Mar 19 2007 09:54:33)

Copyright (c) 1997-2007 The PHP Group

Zend Engine v1.3.0, Copyright (c) 1998-2004 Zend Technologies

    with Zend Extension Manager v1.2.0, Copyright (c) 2003-2006, by Zend Technologies

    with Suhosin v0.9.18, Copyright (c) 2002-2006, by Hardened-PHP Project

    with Zend Optimizer v3.2.2, Copyright (c) 1998-2006, by Zend Technologies

Excellent! We managed to get the Suhosin extension module working. NOTE if checking using phpinfo.php page make SURE you RESTART the apache web server: service httpd restart

Otherwise you won’t see the changes.

Suhosin in PHPinfo page – Screenshot 1

Click to enlarge

suhosin_php_details

Suhosin in PHPinfo page – Screenshot 2 configuration details
Click to enlarge

suhosin_phpinfo2

 

Suhosin Logs and reports

Check your /var/log/messages for logs of Suhosin

EG:

Mar 19 10:28:23 ocean suhosin[32652]: ALERT - Include filename (’http://tutorialgeek.com/slimstat/inc.stats.php’) is an URL that is not allowed (attacker ‘74.6.73.61′, file ‘/home/lireland/public_html/index.php’, line 3) 

Advanced Suhosin Configuration

Configuring Suhosin – example suhosin configuration

You can manually configure options for Suhosin in the php.ini for PHP.  This is the most confusing part that most people get lost at.

If you want advanced configuration to change the default settings form Suhosin you can edit the PHP.ini and add in these values below the extension=suhosin.so

Note this part isn’t required, only for your own liking.

;;;;;;;;;;;;;;;;;;;

; Module Settings ;

;;;;;;;;;;;;;;;;;;;

[suhosin]

; Logging Configuration

suhosin.log.syslog.facility = 9

suhosin.log.use-x-forwarded-for = Off

; Executor Options

suhosin.executor.max_depth = 0

suhosin.executor.include.max_traversal = 4

suhosin.executor.disable_emodifier = Off

suhosin.executor.allow_symlink = Off

; Misc Options

suhosin.simulation = Off

suhosin.apc_bug_workaround = Off

suhosin.sql.bailout_on_error = Off

suhosin.multiheader = Off

suhosin.mail.protect = 1

suhosin.memory_limit = 20

; Transparent Encryption Options

suhosin.session.encrypt = On

suhosin.session.cryptua = On

suhosin.session.cryptdocroot = On

suhosin.session.cryptraddr = 0

suhosin.cookie.encrypt = On

suhosin.cookie.cryptua = On

suhosin.cookie.cryptraddr = 0

; Filtering Options

suhosin.filter.action = 406

suhosin.cookie.max_array_depth = 100

suhosin.cookie.max_array_index_length = 64

suhosin.cookie.max_name_length = 64

suhosin.cookie.max_totalname_length = 256

suhosin.cookie.max_value_length = 10000

suhosin.cookie.max_vars = 100

suhosin.cookie.disallow_nul = On

suhosin.get.max_array_depth = 50

suhosin.get.max_array_index_length = 64

suhosin.get.max_name_length = 64

suhosin.get.max_totalname_length = 256

suhosin.get.max_value_length = 512

suhosin.get.max_vars = 100

suhosin.get.disallow_nul = On

suhosin.post.max_array_depth = 100

suhosin.post.max_array_index_length = 64

suhosin.post.max_totalname_length = 256

suhosin.post.max_value_length = 65000

suhosin.post.max_vars = 200

suhosin.post.disallow_nul = On

suhosin.request.max_array_depth = 100

suhosin.request.max_array_index_length = 64

suhosin.request.max_totalname_length = 256

suhosin.request.max_value_length = 65000

suhosin.request.max_vars = 200

suhosin.request.max_varname_length = 64

suhosin.request.disallow_nul = On

suhosin.upload.max_uploads = 25

suhosin.upload.disallow_elf = On

suhosin.upload.disallow_binary = Off

suhosin.upload.remove_binary = Off

suhosin.session.max_id_length = 128 

That should about do it for this tutorial on Suhosin.

Popularity: 81% [?]

Filed under: Server Security     Tags: Suhosin+Install
No Comment Yet   

PHP for Google App Engine in the works?

Posted by admin on Friday, August 15th 2008   

Digg it

Bookmark it

Stumble it

Email to friend

15
Aug

A recent conversation with a Zend employee revealed some good news for PHP and Google App Engine…
 
Ever since the launch of Google App Engine a little over two months ago there has been a lot of mumbling and grumbling over the lack of PHP support. I am sure that there are good reasons why Google chose to launch with Python but, even so, I expect that this raised several eyebrows (mine included) when App Engine was first released.

It was therefore great to hear from a UK Zend employee that Zend is currently involved in talks with Google regarding PHP and App Engine. I am very pleased to see that some form of progress is being made on this front as it will certainly be interesting to see a PHP API for App Engine. Of course, no timescale has yet to be announced but it is certainly food for thought.

Google_APP

Rolling this over in my head a little more makes me think that there may be some scope for Zend Framework integration in App Engine. The fact that App Engine does not currently provide implementations of any Python frameworks makes the provision of Zend Framework seem less likely, but the very loosely coupled nature of the Zend Framework could greatly simplify deployment (either by Google, or by individual users of App Engine).
I can also not help wondering if this will be somehow integrated into Zend’s various product offerings. For example, could we see a “Create App Engine Project” feature in Zend Studio for Eclipse? And what about debugging tools?

Whatever happens, I think that PHP for App Engine is coming our way, the only question is when. In potentially related news, I was told to keep an eye out for a number of Zend products launches in the Fall (aka Autumn) of this year…

Author: Adam Charnock

Popularity: 100% [?]

Filed under: PHP Hosting Tutorials, SEO Articles     Tags: Google+APP+Engine
2 Comments   

How to Add Streaming Video to your Web Site

Posted by admin on Friday, August 15th 2008   

Digg it

Bookmark it

Stumble it

Email to friend

15
Aug

If adding streaming audio to a web site is a black art, what about video? Moving images are really the final step in the evolution of the web. Streaming video completes the loop, giving a communication tool that offers all the advantages of video tape without the problems of distributing hundreds of cassettes.

So why has video taken so long to catch on? The answer is simple - bandwidth. Reasonable quality video in an eight-centimetre window needs broadband speeds if it is to work. In reality this means between 200-400kbps (kilo bits per second).

That’s 25-50 kilobytes of information for every second you wish to stream, or 1.5 - 3Mbytes for every minute. As you can see, the file sizes get very big very quickly. My evaluations have shown that a stream rate of about 225kbps is required for reasonable, watchable video in a small-ish window. That’s five times faster that a dial-up modem can deliver and about half the speed of a typical broadband or office LAN (Local Area Network).

In comparison, you can stream reasonable quality audio at around 32kbps - low enough for even dial-up modems. In reality, things are not so simple. The trick with streaming video and audio is to pick a streaming rate that is SLOWER than your typical connection speed. That way, the end user’s PC buffers the incoming signal so that you have something “in reserve” if the connection falters a little.

streaming-video

If the connection doesn’t play ball you run the risk of a buffer overrun, which leads to that annoying stuttering and freezing that you so often see on the net.

But before you all rush out to put the latest corporate video on your intranet I suggest you speak to your techies first. While most corporate intranets are more than capable of streaming a file at 200-300kbps we have overlooked one problem.

What happens if 5,000 people all want to view it at once? Can your server handle that many people? Can the infrastructure cope with that much data? Will you stop other people from carrying on their essential work if you take up that much bandwidth?
Assuming that your office network is robust enough to cope what exactly can you stream and how? You can take any MPEG, WMV or Quicktime movie and stream it over the web. You can even convert DVD material into a suitable format and stream that too, although the level of complexity goes up accordingly.

DVDs are actually very clever devices made up of a host of different computer files. The trick if you wish to stream them is to extract the video and audio files from the DVD using a process called ripping.

Once extracted you can then convert the resultant .VOB files to smaller, faster MPEG or WMV files. Unfortunately, there are a lot of industry standards out there and one-size fits all approach is virtually doomed to failure.

PCs running MS Windows are generally happy receiving Window Media Files (.WMV), whereas Macintosh users are going to be happier with Quicktime movies. But if you host all your videos as Quicktime, the chances are that Window users won’t be able to view them. MPEG files are great, but again, older versions of Windows Media Player won’t like them.

A solution is to offer users a choice of file formats on the same page and let your users choose. Or, given that Macintosh users are in the minority anyway, just ignore them and settle for .WMV - I know it’s harsh, but if they are really keen they will download and install the Windows Media Player anyway.

Another solution involves using Macromedia Flash, the plug-in for which can be found on more than 90-95% of all machines in the world apparently. Flash is truly cross-platform, but your end user must have the plug-in Installed otherwise all they will see is a blank box.

The other advantage of using Flash is that you can build the video player right into the page, complete with stop, play, pause and rewind buttons.

Learning to stream video takes time. Get the stream rate wrong and your videos will stutter like Norman Collier. Get the CODEC wrong and half your users will hear the audio, but not see the video. Rip your DVD incorrectly and you will have video and audio that don’t actually synch up.

Frequently Asked Questions

Q. What is streaming video? A. It is video delivered to your computer that can be watched while it is still downloading.

Q. What do viewers need to have on their computer? A. A soundcard and speaker(s) or headphones, their normal browser software and a so-called plug-in - a small piece of software that converts the data into sound. If you opt for .WMV streaming they will also need the Windows Media Player.

Q. This all sounds expensive - is it? A. Not really. The programs needed to convert video into a streaming format are very reasonable. I recommend MSIVideo (http://hop.clickbank.net/?snichols/msincome) Its great, very easy to use and only costs $39.95. Another alternative is Webmaster media maker (http://www.webmastermediamaker.com/?hop=snichols)

Q. What is the quality like? A. Judge for yourself - visit http://www.infotechcomms.co.uk/info10.htm and watch the demonstration programme. The trick is to get the quality as high as you can, but still make it playable on an average modem-equipped home computer.

About the Author
Steve Nichols is a freelance journalist who runs InfoTech Communications (http://www.infotechcomms.co.uk). A background in radio means that Steve was ideally placed to take advantage of the arrival of streaming media via the web.

Popularity: 100% [?]

Filed under: Streaming Media     Tags: Streaming+Video+Website
1 Comment   

The Truth About PHP Variables

Posted by admin on Friday, August 15th 2008   

Digg it

Bookmark it

Stumble it

Email to friend

15
Aug

This article examines how PHP handles passing of variables internally, as well as how this relates to memory usage. This information is very useful for any professional PHP developer as it shows how passing variables by reference will normally result in more (not less) memory being used.

The Truth About PHP Variables
 
I wanted to write this post to clear up what seems to be a common misunderstanding in PHP - that using references when passing around large variables is a good way save memory. To fully explain this I will need to explain how PHP handles variables internally. I hope that you will find this interesting and useful and that it helps dispel some myths around references and memory management in PHP. First off, lets cover the basics…
Basic References in PHP(Note: If you are already familiar with references in PHP then feel free to skip this section)

PHP

In PHP it is possible to assign variables by value or by reference. The former method is the most common, and should look very familiar to you:

view plaincopy to clipboardprint?
<?php  
//Example 1: Assigning variables by value (the ’standard’ way)  
$var1 = ‘hello!’;  
$var2 = $var1;  
$var2 = ‘goodbye!’;  
echo $var1; // Produces: hello!  
echo “<br />\n”;  
echo $var2; //Produces: goodbye!  
?> 
<?php
//Example 1: Assigning variables by value (the ’standard’ way)
$var1 = ‘hello!’;
$var2 = $var1;
$var2 = ‘goodbye!’;
echo $var1; // Produces: hello!
echo “<br />\n”;
echo $var2; //Produces: goodbye!
?>
 
This should be no surprise to you, just simple assigning of variables in PHP. The next example is very similar, but we assign $var2 by reference rather than by value.

view plaincopy to clipboardprint?
<?php  
//Example 2: Assigning variables by reference  
$var1 = ‘hello!’;  
$var2 =& $var1; // Notice the ampersand. This means $var2   
                // is a reference to $var1  
$var2 = ‘goodbye!’ // because $var2 is a reference to $var1,   
                   // both variables now have the value ‘goodbye!’;  
echo $var1; // Produces: goodbye!  
echo “<br />\n”;  
echo $var2; //Produces: goodbye!  
?> 
<?php
//Example 2: Assigning variables by reference
$var1 = ‘hello!’;
$var2 =& $var1; // Notice the ampersand. This means $var2
                // is a reference to $var1
$var2 = ‘goodbye!’ // because $var2 is a reference to $var1,
                   // both variables now have the value ‘goodbye!’;
echo $var1; // Produces: goodbye!
echo “<br />\n”;
echo $var2; //Produces: goodbye!
?>
 
This may be more surprising to some of you, so I will explain what is happening. The first step is no different, we simply initialise $var1 with a value of ‘hello!’. However, in the next step we assign $var1 to $var2 using the ‘=&’ operator, which causes a reference to $var1 to be passed, rather than the actual contents of $var1. This means that both variables point to the same data in memory, so any changes to either variable will affect the other.

For more information on this I would recommend reading the References Explained section of the PHP Manual as it covers this topic in much more detail.

How PHP Handles Variables Internally (using zvals!)
While the above explanation of references is sufficient for a general understanding, it is often useful to understand how PHP handles variable assignment internally. This is where we introduce the concept of the zval.

zvals are an internal PHP structure which are used for storing variables. Each zval contains various pieces of information, and the ones we will be focusing on here are as follows:

The actual data stored within the zval - In our example this would be either ‘hello!’ or ‘goodbye!’
is_ref Boolean flag
A ref_count counter
The zval also knows the type of data it contains, but this is not especially relevant here so it has been omitted from the above list.

The first item in our list, the actual data, does not require much explanation. The second item on this list (is_ref) indicates if variables should address this zval by value or by reference, the implications of which are addressed shortly. The third item (ref_count) stores the number of variables that currently address this zval. If ref_count ever reaches zero (for example, if you call unset()) then PHP assumes that it can remove the zval and free up the memory it was using.

Now this bit is important: You may think that the ref_count value is only used when dealing with a reference (i.e. when is_ref=true), but this is not the case. The ref_count variable is used regardless of the value of is_ref. So what does this mean?

Being A Little Bit Clever
This is where, as the headline suggests, PHP is a little bit clever. When you assign a variable by value (such as in example 1) it does not create a new zval, it simply points both variables at the same zval and increases that zval’s ref_count by one. “Wait!” I hear you cry, “Isn’t that passing by reference?” Well, although it sounds the same, all PHP is doing is postponing any copying until it really has to - and it knows this because is_ref is still false. “Hum, so how does it work?” Ok, here is an example:

view plaincopy to clipboardprint?
<?php  
//Example 3a: Assigning variables by value (but with more detail)  
 
//Here our zval is created for $var1.  
$var1 = ‘hello!’;  
//Our zval now has ref_count=1, is_ref=false  
 
//We now assign $var1 to $var2  
$var2 = $var1;  
//Our zval now has ref_count=2, is_ref=false  
 
debug_zval_dump($var2); //Produces: string(6) “hello!” refcount(3)  
//(Why refcount(3)? See “An important note on debug_zval_dump()”)  
 
//We now assign a new value to $var2. So what happens to our zval?  
$var2 = ‘goodbye!’;  
//Read on to find out…  
 
?> 
<?php
//Example 3a: Assigning variables by value (but with more detail)

//Here our zval is created for $var1.
$var1 = ‘hello!’;
//Our zval now has ref_count=1, is_ref=false

//We now assign $var1 to $var2
$var2 = $var1;
//Our zval now has ref_count=2, is_ref=false

debug_zval_dump($var2); //Produces: string(6) “hello!” refcount(3)
//(Why refcount(3)? See “An important note on debug_zval_dump()”)

//We now assign a new value to $var2. So what happens to our zval?
$var2 = ‘goodbye!’;
//Read on to find out…

?>
 
An important note on debug_zval_dump(): php.net says this function “dumps a string representation of an internal Zend value to output.” This is true, but calling this function inherently causes another reference to the variable to be created, so you can (in these examples) subtract one from the ref_count value given in the output.

In the above example we see how both $var1 and $var2 refer to the same zval (as can be seen by the call to debug_zval_dump()). So what happens on the last line when we assign a new value to $var2? Does $var1 change too? Of course the answer is no, but why?

When we assign ‘goodbye!’ to $var2 in the example above, PHP examines the is_ref value of the underlying zval. If is_ref is false (as it is in this example) PHP knows that it can only change the value of the zval if the ref_count is 1 (as the change will not affect any other variables). However, in our example the ref_count is 2, therefore PHP realises that it is not allowed to change the zval’s value and so creates another zval to which $val2 is the associated. The is illustrated by the finished example below:

view plaincopy to clipboardprint?
<?php  
//Example 3b: Assigning variables by value (the complete example)  
 
//Here our zval is created for $var1.  
$var1 = ‘hello!’;  
//Our zval now has value=’hello!’, ref_count=1, is_ref=false  
 
//We now assign $var1 to $var2  
$var2 = $var1;  
//Our zval now has value=’hello!’, ref_count=2, is_ref=false  
 
debug_zval_dump($var2); //Produces: string(6) “hello!” refcount(3)  
//(Why refcount(3)? See “An important note on debug_zval_dump()”)  
 
//We now assign a new value to $var  
$var2 = ‘goodbye!’;  
//We now have two zvals:  
//   The first: value=’hello!’, ref_count=1, is_ref=false  
//   The second: value=’goodbye!’, ref_count=1, is_ref=false  
 
?> 
<?php
//Example 3b: Assigning variables by value (the complete example)

//Here our zval is created for $var1.
$var1 = ‘hello!’;
//Our zval now has value=’hello!’, ref_count=1, is_ref=false

//We now assign $var1 to $var2
$var2 = $var1;
//Our zval now has value=’hello!’, ref_count=2, is_ref=false

debug_zval_dump($var2); //Produces: string(6) “hello!” refcount(3)
//(Why refcount(3)? See “An important note on debug_zval_dump()”)

//We now assign a new value to $var
$var2 = ‘goodbye!’;
//We now have two zvals:
//   The first: value=’hello!’, ref_count=1, is_ref=false
//   The second: value=’goodbye!’, ref_count=1, is_ref=false

?>
 
So we can see that, in the case of passing-by-value, PHP only copies data if a value is changed.

For the sake of completeness, here is an example where we pass-by-reference;

view plaincopy to clipboardprint?
<?php  
//Example 4: Assigning variables by value (the complete example)  
 
//Here our zval is created for $var1.  
$var1 = ‘hello!’;  
//Our zval now has value=’hello!’, ref_count=1, is_ref=false  
 
//We now assign $var1 to $var2  
$var2 =& $var1;  
//Our zval now has value=’hello!’, ref_count=2, is_ref=true  
 
debug_zval_dump(&$var2); //Produces: &string(6) “hello!” refcount(3)  
//(Why refcount(3)? See “An important note on debug_zval_dump()”)  
 
//We now assign a new value to $var  
$var2 = ‘goodbye!’;  
//We still have one zval, but with a    
//new value: value=’goodbye!’, ref_count=2, is_ref=true  
 
debug_zval_dump(&$var1); //Produces: &string(8) “goodbye!” refcount(3)  
debug_zval_dump(&$var2); //Produces: &string(8) “goodbye!” refcount(3)  
//(Why refcount(3)? See “An important note on debug_zval_dump()”)  
 
?> 
<?php
//Example 4: Assigning variables by value (the complete example)

//Here our zval is created for $var1.
$var1 = ‘hello!’;
//Our zval now has value=’hello!’, ref_count=1, is_ref=false

//We now assign $var1 to $var2
$var2 =& $var1;
//Our zval now has value=’hello!’, ref_count=2, is_ref=true

debug_zval_dump(&$var2); //Produces: &string(6) “hello!” refcount(3)
//(Why refcount(3)? See “An important note on debug_zval_dump()”)

//We now assign a new value to $var
$var2 = ‘goodbye!’;
//We still have one zval, but with a 
//new value: value=’goodbye!’, ref_count=2, is_ref=true

debug_zval_dump(&$var1); //Produces: &string(8) “goodbye!” refcount(3)
debug_zval_dump(&$var2); //Produces: &string(8) “goodbye!” refcount(3)
//(Why refcount(3)? See “An important note on debug_zval_dump()”)

?>
 
As expected, we can see that the zval for both $var1 and $var2 has changed to a value of ‘goodbye!’ and has a ref_count of 2.

A Little More Complex
So now we know how PHP handles values and references, and isn’t it is all wonderfully exciting? “Oh yes! Please tell me more!” I hear you say? Ok then…

There is one last thing to mention in this area, which I think is especially relevant to those of you who love to (ahem) save memory by passing around references - what happens when values and references meet.

You may have noticed that the zval’s is_ref flag does not permit a zval to be both a reference and a value at the same time (as it is either true or false). On the face of it this is probably for the best as I suspect it could lead to all kinds of strangeness from an internal perspective. However, a result of this is that if you are using a variable by value in several places (i.e. the variables underlying zval has a ref_count greater than 1) and then pass it by reference (for example, to a function), PHP will have to copy the value into a entirely new zval in order to set the is_ref flag to true. The following example illustrates how this can result in substantially increased memory usage:

view plaincopy to clipboardprint?
<?php  
//Example 5: Showing how mixing references and values can lead   
//           to increased memory consumption  
 
memory_show_usage(); //Zero bytes  
 
$v1 = str_repeat(’0′, 100000);//Generate 100kb of dummy data  
memory_show_usage(); //100kb  
 
$v2 = $v1;  
//We now have two variables pointing to a zval in the form:  
//   is_ref=false, ref_count=2  
memory_show_usage(); //100kb  
 
$r1 =& $v2; //We now assign our value by reference  
memory_show_usage(); //200kb  
//PHP has now had to create a second zval in the form:  
//   is_ref=true, ref_count=1  
 
$v3 = $r1; //We now assign second zval by value  
memory_show_usage(); //300kb  
//PHP has now had to create a third zval in the form:  
//   is_ref=false, ref_count=1  
 
$v4 = $v3; //Now assign by value  
memory_show_usage(); //300kb (no increase)  
//Our third zval now has a ref_count of 2  
 
//Both $v3 and $v4 now have the same zval, which may only be   
//passed by value as it has a ref_count greater than one  
 
$r2 =& $v3; //So now we assign $v3 by reference  
memory_show_usage(); //400kb  
//Here PHP has been forced to create a fourth zval with yet   
//another copy of the data. The new zval is in the form:  
//    is_ref=true, ref_count = 1  
 
//Simple function to show memory use from a baseline  
function memory_show_usage(){  
    static $baseline = null;  
    if(is_null($baseline)){  
        //Initialise to get an accurate memory use value  
        $baseline = 1;  
        $baseline = memory_get_usage();  
    }  
      
    echo (memory_get_usage() - $baseline) . ” bytes\n”;  
}  
 
?> 
<?php
//Example 5: Showing how mixing references and values can lead
//           to increased memory consumption

memory_show_usage(); //Zero bytes

$v1 = str_repeat(’0′, 100000);//Generate 100kb of dummy data
memory_show_usage(); //100kb

$v2 = $v1;
//We now have two variables pointing to a zval in the form:
//   is_ref=false, ref_count=2
memory_show_usage(); //100kb

$r1 =& $v2; //We now assign our value by reference
memory_show_usage(); //200kb
//PHP has now had to create a second zval in the form:
//   is_ref=true, ref_count=1

$v3 = $r1; //We now assign second zval by value
memory_show_usage(); //300kb
//PHP has now had to create a third zval in the form:
//   is_ref=false, ref_count=1

$v4 = $v3; //Now assign by value
memory_show_usage(); //300kb (no increase)
//Our third zval now has a ref_count of 2

//Both $v3 and $v4 now have the same zval, which may only be
//passed by value as it has a ref_count greater than one

$r2 =& $v3; //So now we assign $v3 by reference
memory_show_usage(); //400kb
//Here PHP has been forced to create a fourth zval with yet
//another copy of the data. The new zval is in the form:
//    is_ref=true, ref_count = 1

//Simple function to show memory use from a baseline
function memory_show_usage(){
    static $baseline = null;
    if(is_null($baseline)){
        //Initialise to get an accurate memory use value
        $baseline = 1;
        $baseline = memory_get_usage();
    }
   
    echo (memory_get_usage() - $baseline) . ” bytes\n”;
}

?>
 
Although this example only assigns variables directly, the same principles apply when performing function calls where parameters are passed by reference. You can see that, unless the developer is completely consistent, passing variables by reference can easily lead to increased memory usage.

Conclusion
 
If you concern is to conserve memory then it is best to simply pass data by value as the PHP language is smart enough to conserve memory automatically. If you really must pass a value by reference then make sure that it is done consistently as this will avoid consuming many times more memory (and CPU cycles) than is necessary. Alternatively you could wrap your data in an object as PHP5 (but not PHP4) will pass this by reference as the default behaviour.

As a side note I would like to point out that side affecting function parameters (which may be your intention if you are passing by reference) is generally discouraged as it can make some bugs very hard to track down (a similar argument to that against global variables).

Author :    Derek Rethans

Popularity: 86% [?]

Filed under: PHP Hosting Tutorials     Tags: PHP+Variables
No Comment Yet   

Windows Or Linux — Which One Is Better Option For Web Hosting?

Posted by admin on Sunday, August 10th 2008   

Digg it

Bookmark it

Stumble it

Email to friend

10
Aug

Once a web site is ready, the next confusing thing is the server on which the web site goes on. Deciding on a web hosting service is something that might get anybody perplexed. There are mainly two types of website hosting services — Windows and Linux. If the business is small then you can even try out the Shared Linux and Windows hosting service. Windows as well as Linux website host services have different benefits and limitations.

Linux_Windows

Linux hosting is one of the most common and significant hosting service on the net. The main reason for this web hosting is that many companies which are using it are open sources and quite affordable compared to Windows. Linux is much easier to manage as the business grows online. Windows hosting supports all operational functions of Windows system. It maintains programming frameworks such as ColdFusion and ASP.net. It also backs SQL servers which is extremely useful when creating a website regarding a searchable list. Windows hosting service is apt for people who are used to Microsoft based technologies or equipments. The biggest difference between these two hosting services is the cost factor. Linux services are much low-priced in comparison to Windows. Money does play an important in website hosting especially when new web owners are starting off. But, the main reason for Windows hosting service costs to be higher is the fact that many Windows technologies are licensed. Windows also scores over Linux in the programming department; there are many Windows softwares which are not supported on Linux operating systems. After drafting out your needs, you can also consult professionals in the web site hosting field on which is a better option. But, it is always advisable to weigh the pros and cons before making that choice, so that you do not regret in any possible where. There are many hosting companies that can help you with the right web hosting solution which will take away all your tension and your entire job will be done within moments. But, make sure to do a reference check before hiring any company’s service.
Author: Arvind Sharma

Popularity: 94% [?]

Filed under: Web Hosting Articles     Tags: Linux+Or+Windows, Linux+Windows+Server
No Comment Yet   

Introduction to Microsoft FrontPage

Posted by admin on Sunday, August 10th 2008   

Digg it

Bookmark it

Stumble it

Email to friend

10
Aug

Microsoft FrontPage 2002 permits consumers to take total control of their Web site, from how it looks and performs, to maintaining and managing its content ..
FrontPage is software that allows consumers to design Web sites without an in-depth understanding of mark-up languages such as HTML and XML. The software, an integral component of the Microsoft Office suite, gives users, especially novices, the ability to create, edit and add content to Web sites.
FrontPage is designed as a “what you see is what you get” or “WYSIWYG” application. It is a well-designed Web page editor, loaded with easy-to-use options and page elements that allow users to create a decent Web site quickly. The application is designed to mimic Microsoft Office in look and feel, allowing users to easily build Web pages with drag-and-drop functionality. With the software installed on a user’s computer, they can quick develop Web documents with elements drawn from other Office documents.

Front_Page

While the software makes the composition of a Web site simple, the down side of the software is that it does not conform strictly to compliant mark-up language standards. As a result, the code that the software generates has been described as bloated. For more control over the creation of Web sites, professionals hence elect to use more advanced Web design software packages.

FrontPage is mainly used by neophytes, but is quite an effective tool to get beginners online and publishing their Web sites. For this reason, the software is quite popular. One of the most powerful aspects built into FrontPage is its site management capability. The same interface that is used to develop Web pages is also used to manage and manipulate those pages online.

As a Web site grows, the content contained within the site can become outdated or inconvenient to update. Keeping up with the changes made to a site and ensuring that Web content is kept current is a time consuming task, often considerably larger than the initial development of the site. The use of FrontPage provides users with the power to easily manage content on a site-wide basis instead of on the level of the individual Web page.

The software provides a high-level view of site architecture. It also provides the capability for direct online integration and deployment of content created by FrontPage through Microsoft FrontPage Server Extensions.

FrontPage Server Extensions are the server-side power behind FrontPage that lets the software interact directly with the Web server. Most sophisticated Web hosting firms offer FrontPage Server Extensions to both their customers and resellers. Server extensions are native to the Windows hosting platform, but are also widely available on Linux hosting platforms. Through the server extensions, users can upload and maintain their Web site directly through the FrontPage application. Web authors can also utilize other innovative features, such as traffic reports that can be generated daily, weekly or month. These reports can track hits, referred domains and search strings. The software also allows Web authors to develop database-driven Web sites. The Database Interface Wizard simplifies the creation of dynamic databases that can interact with the Web site.

The most unique element of FrontPage is its groupware function, known as “SharePoint.” SharePoint is a team Web site solution that allows users to edit straight from their browser. No Web authoring skills are required in order to add and edit content to a SharePoint-based site, which means that everyone within a work group or a broad organization can collaborate on projects, share documents and communicate more effectively.

While FrontPage has always attempted to offer a tremendous number of features, the software really functions as an easy-to-use, simple and straightforward Web authoring tool. For more code-intensive Web authoring, users need to select another package, but FrontPage should suffice for the novice.

Popularity: 83% [?]

Filed under: Windows Web Hosting     
No Comment Yet   
Newer Entries »
« Older Entries
feeds
Subscribe to our article via RSS
Subscribe via email subscriptions

Advertisments


Want to put your ad banner here, contact us

  • Recent Entries
  • Most Popular
  • Recent Comments
  • 10 Major Reasons To Switch To Linux
  • Windows Server 2003 Network Infrastructure
  • Cisco’s Catalyst 6500
  • Registro de dominio
  • How does SAS 70 Work?
  • Templates for E-Commerce Web Hosting
  • Using JSP as a Host Server
  • Developing Cold Fusion Hosting
  • E-commerce Web Hosting
  • VPS Media - My New Hosting Provider
  • PHP for Google App Engine in the works?
  • How to Add Streaming Video to your Web Site
  • Windows Or Linux -- Which One Is Better Option For Web Hosting?
  • The Truth About PHP Variables
  • Introduction to Microsoft FrontPage
  • Old Photos Free Wordpress Template
  • Suhosin Install Guide
  • A Brief Introduction on Shared Web Hosting
  • VPS Media - My New Hosting Provider
  • Web Design & Search Engine Ranking
  • Pom: I think CAT is the most famous data center in Thailand. Pom.
  • Martin: What data center you recomend in Asia ? Martin.
  • Ana: What if i want to use frame ? Thanks. Ana
  • Dave: Have you heard back from Zend ? Dave.
  • Tina: What a wonderful article ! Tina.

Search

Categories

  • Uncategorized (2)
  • cheap linux web hosting (3)
  • Dedicated Server (2)
  • Fantastico (1)
  • Firewall (1)
  • Internet Security (1)
  • Linux Web Hosting (3)
  • Load Balancing (1)
  • Plesk Tutorial (1)
  • PHP Hosting Tutorials (3)
  • Reseller Hosting (1)
  • SEO Articles (2)
  • Server Security (2)
  • Streaming Media (2)
  • VPS Hosting (2)
  • Web Design (2)
  • Web Hosting (3)
  • Web Hosting Articles (2)
  • WHM Tutorials (1)
  • Windows Web Hosting (3)
  • Wordpress Template (13)
  • Cold Fusion Hosting (1)
  • JSP (1)
  • Network (1)

Meta

  • Log in
  • Valid XHTML
  • Valid CSS

Archives

  • November 2008 (3)
  • October 2008 (5)
  • September 2008 (3)
  • August 2008 (41)

Blogrool

  • Fashion Blog
  • Finance Blog
  • Jewelry Blog
  • SEO
  • SEO Blog
  • Website performance
  • Your Ad Here !

Live Traffic

Subscribe

  • technorati add aol netvibes rojo myyahoo modern freedictionary subrss chicklet plusmo newsburst ngsub wwgthis subscribes

Browse Our Tag Archives

2+columns+Wordpress+templates 3+column+Wordpress+templates 3+column+Wordpress+themes 3+columns+Wordpress+templates Ajax+Application+Java+script APF+Firewall Architecture+Wordpress+templates Business+Wordpress+templates Cisco Dedicated+Server Dedicated+Server+Web+Hosting Design+Wordpress+templates Developing+Cold+Fusion+Hosting E-Commerce+Web+Hosting Free+Wordpress+templates Google+APP+Engine JSP+Hosting Linux Linux+Or+Windows Linux+Web+Hosting Linux+Windows+Server Load+Balancing Personal+Page+Wordpress+templates Photoblog+Wordpress+templates PHP+Tutorials PHP+Variables Plesk+Tutorial Reseller+Web+Hosting SEO+Articles Server+Load+Balancing Server+Security Share+Web+Hosting Soccer+Wordpress+templates Streaming+Video+Website Suhosin+Install Tech + Wordpress + templates VPS+Media VPS+Server Web+Design+Search+Engine Wedding+Wordpress+templates WHM+FLASH+TUTORAIL Windows+Web+Hosting Winows+Network Wordpress+templates

Our Editor Recommended

  • Fashion Blog
  • Technology Blog
  • SEO Blog
  • Web Hosting Blog
  • Domain Name

Top Commentators

    • No commentators.

Most Popular

  • PHP for Google App Engine in the works?
  • How to Add Streaming Video to your Web Site
  • Windows Or Linux -- Which One Is Better Option For Web Hosting?
  • The Truth About PHP Variables
  • Introduction to Microsoft FrontPage
  • Old Photos Free Wordpress Template
  • Suhosin Install Guide
  • A Brief Introduction on Shared Web Hosting
  • VPS Media - My New Hosting Provider
  • Web Design & Search Engine Ranking

Recent Updated Post

  • Windows Server 2003 Network Infrastructure
  • 10 Major Reasons To Switch To Linux
  • Cisco's Catalyst 6500
  • Registro de dominio
  • How does SAS 70 Work?
  • Templates for E-Commerce Web Hosting
  • Using JSP as a Host Server
  • Developing Cold Fusion Hosting
  • E-commerce Web Hosting
  • VPS Media - My New Hosting Provider

©2008 Web Hosting Blog

Disclaimer: All data and information provided on this site is for informational purposes only.

Powered by Wordpress Sponser By Jewelry Blog | Web Hosting Blog ByThailand Web Hosting