Upload Share and Earn

Thursday, November 22, 2007

Monday, October 22, 2007

PHP Code Optimization Tips

(1) If a method can be static, declare it static. Speed improvement is by a factor of 4. echo is faster than print.
(2) Use echo's multiple parameters instead of string concatenation. Set the maxvalue for your for-loops before and not in the loop.
(3)Unset your variables to free memory, especially large arrays.
(4) Avoid magic like __get, __set, __autoload
(5)require_once() is expensive
(6)Use full paths in includes and requires, less time spent on resolving the OS paths.
(7)If you need to find out the time when the script started executing, $_SERVER[’REQUEST_TIME’] is preferred to time()
(8)See if you can use strncasecmp, strpbrk and stripos instead of regex
(9)str_replace is faster than preg_replace, but strtr is faster than str_replace by a factor of 4 (10)If the function, such as string replacement function, accepts both arrays and single characters as arguments, and if your argument list is not too long, consider writing a few redundant replacement statements, passing one character at a time, instead of one line of code that accepts arrays as search and replace arguments.
(11)It's better to use select statements than multi if, else if, statements.
(12)Error suppression with @ is very slow.
(13)Turn on apache's mod_deflate
(14)Close your database connections when you're done with them
(15)$row[’id’] is 7 times faster than $row[id]
(16)Error messages are expensive
(17)Do not use functions inside of for loop, such as for ($x=0; $x < count($array); $x) The count() function gets called each time.
(18)Incrementing a local variable in a method is the fastest. Nearly the same as calling a local variable in a function.
(19)Incrementing a global variable is 2 times slow than a local var.
(20)Incrementing an object property (eg. $this->prop++) is 3 times slower than a local variable.
(21)Incrementing an undefined local variable is 9-10 times slower than a pre-initialized one. (22)Just declaring a global variable without using it in a function also slows things down (by about the same amount as incrementing a local var). PHP probably does a check to see if the global exists.
(23)Method invocation appears to be independent of the number of methods defined in the class because I added 10 more methods to the test class (before and after the test method) with no change in performance.
(24)Methods in derived classes run faster than ones defined in the base class.
(25)A function call with one parameter and an empty function body takes about the same time as doing 7-8 $localvar++ operations. A similar method call is of course about 15 $localvar++ operations.
(26)Surrounding your string by ' instead of " will make things interpret a little faster since php looks for variables inside "..." but not inside '...'. Of course you can only do this when you don't need to have variables in the string.
(27)When echoing strings it's faster to separate them by comma instead of dot. Note: This only works with echo, which is a function that can take several strings as arguments.
(28)A PHP script will be served at least 2-10 times slower than a static HTML page by Apache. Try to use more static HTML pages and fewer scripts.
(29)Your PHP scripts are recompiled every time unless the scripts are cached. Install a PHP caching product to typically increase performance by 25-100% by removing compile times. Cache as much as possible. Use memcached - memcached is a high-performance memory object caching system intended to speed up dynamic web applications by alleviating database load. OP code caches are useful so that your script does not have to be compiled on every request
(30)When working with strings and you need to check that the string is either of a certain length you'd understandably would want to use the strlen() function. This function is pretty quick since it's operation does not perform any calculation but merely return the already known length of a string available in the zval structure (internal C struct used to store variables in PHP). However because strlen() is a function it is still somewhat slow because the function call requires several operations such as lowercase & hashtable lookup followed by the execution of said function. In some instance you can improve the speed of your code by using an isset() trick.
Ex. if (strlen($foo) < 5) { echo "Foo is too short"; }vs.if (!isset($foo{5})) { echo "Foo is too short"; }
(31)Calling isset() happens to be faster then strlen() because unlike strlen(), isset() is a language construct and not a function meaning that it's execution does not require function lookups and lowercase. This means you have virtually no overhead on top of the actual code that determines the string's length.
(32)When incrementing or decrementing the value of the variable $i++ happens to be a tad slower then ++$i. This is something PHP specific and does not apply to other languages, so don't go modifying your C or Java code thinking it'll suddenly become faster, it won't. ++$i happens to be faster in PHP because instead of 4 opcodes used for $i++ you only need 3. Post incrementation actually causes in the creation of a temporary var that is then incremented. While pre-incrementation increases the original value directly. This is one of the optimization that opcode optimized like Zend's PHP optimizer. It is a still a good idea to keep in mind since not all opcode optimizers perform this optimization and there are plenty of ISPs and servers running without an opcode optimizer.
(33)Not everything has to be OOP, often it is too much overhead, each method and object call consumes a lot of memory.
(34)Do not implement every data structure as a class, arrays are useful, too
(35)Don't split methods too much, think, which code you will really re-use
(36)You can always split the code of a method later, when needed (37)Make use of the countless predefined functions
(38)If you have very time consuming functions in your code, consider writing them as C extensions
(39)Profile your code. A profiler shows you, which parts of your code consumes how many time. The Xdebug debugger already contains a profiler. Profiling shows you the bottlenecks in overview
(40)mod_gzip which is available as an Apache module compresses your data on the fly and can reduce the data to transfer up to 80% Excellent Article about optimizing php by John Lim


SRC:http://reinholdweber.com/?p=3

Wednesday, October 17, 2007

List Of PHP frame works

'Cake PHPhttp://cakephp.org/

Achievo Toolkithttp://www.achievo.org/atk
AjaxAChttp://ajax.zervaas.com.au/
Ambivalencehttp://amb.sourceforge.net/
binarycloudhttp://www.binarycloud.com/index.php/Links/HomePage
Biscuithttp://bennolan.com/biscuit/
Blue Shoes PHP Frameworkhttp://www.blueshoes.org/en/framework/
Core Enterprise for PHPhttp://jaxn.org/blog/categories/6-cep
Easy PHP Frameworkhttp://epf.molhanec.net/
eZ Componentshttp://ez.no/products/ez_components
FastFramehttp://codejanitor.com/wp/apps/fastframe/
Green Orange PHP Frameworkhttp://www.apple.com/downloads/macosx/unix_open_source/green orangephpframework.html
Interjinnhttp://www.interjinn.com/
ISMOhttp://ismo.sourceforge.net/
Ksysalishttp://www.interakt.ro/products/Krysalis/index.php
Logicreatehttp://www.logicreate.com/
Medusahttp://medusa.tigris.org/
Mojavihttp://www.mojavi.org/
PEARhttp://pear.php.net
Phramehttps://www.phrame.org/
php.MVChttp://www.phpmvc.net/
PHP On Traxhttp://phpontrax.com/
Popoonhttp://www.popoon.org/
Prado PHP Frameworkhttp://www.xisc.com/
Seagull Frameworkhttp://seagull.phpkitchen.com/
Sitellitehttp://www.sitellite.org/
SMART3 PHP Frameworkhttp://smart.open-publisher.net/
Sourdoughhttp://sourdough.phpee.com/
Studshttp://www.mojavelinux.com/projects/studs/
Web Application Component Toolkit (WACT)http://www.wact.org
Zend Frameworkhttp://www.zend.com/collaboration
ZNFhttp://znf.zeronotice.com/
Zoophttp://www.zoopframework.com/

Wednesday, October 3, 2007

Tab Based Browsing Navigation in Web Application

Tab Bassed Browse Navigation

If you want tab based Browse Navigation In a web application
you need to use a Ajax based javascript code to implement that

For more info Click Here http://www.activewidgets.com/

Wednesday, September 26, 2007

Ajax Tutorial

Ajax Tutorial



Ajax is simple known asynchronous javascript and xml which is new technique of writing web applications more user friendly.This is first started using by
big companies like google,yahoo etc

How to Create Dynamic check box in php ?

while( )
{

input type="checkbox" name="myboxes[]"

}


you can access dynamic check boxes thru myboxes[] array

using loop

How to create Dynamic Drop down in php pr dynamic list box?

How to create Dynamic Drop down or dynamic list box in php?


Ans) It is very Simple to load
(select)
(option width="20" heigth="20") $filename (/option)
(/select)

where $filename is the value retrived from the database


This is the sample code where we are retriving valus from table in database and loading in to drop down box.

select box name plays an important here in posting the information

thank you
hope this helps for you

Thursday, September 13, 2007

PHP Interview Questions From yahoo

Hi Guys,

You all might be busy with your work. I hope this will be useful
information for you all. Following are the questions asked in the
interview of Yahoo!, last sunday.

PHP
----
1. Differences between sessions and cookies
2. Disadvantage of sessions
3. How to upload file using Get method
4. What is the max size of post method
5. How to store sessions in database
6. "a_b_2_3__5_ 6_8_a_b_2_ 4" given as a string Explode it
using Underscrore and find out unique alphanumeric existences and
their no.of occurences
7. Explain DB.ini file configuration in PHP
8. Registar_globals
9. connect,pconnet differences
10. setting php configurations dynamically
11. Soap Vs Rest
12. Error handling when an object calls an function which is not
existing in class
13. Implementation of Destructors in PHP4
14. In php5, in a class
__construct( ) is one method and another method name same as class name
Which will be called when object is intialized
15. Writing Code snippet for Stack implementation using OOPs.

Javascript
-----------
1. OOPs(inheritence and polymorphism) implementation in Javascript
2. Implement Trim functionality in javascript
3. Explain different types of objects(Native ,Host and user Defined) in
javascript
4. Try to extend Trim() method on String object
5. Explain all parameters of Window.open( )
6. How to avoid Permission denied error when child window accesses
parent window's elements.
7. Enabling and disabling Client's cookie settings using javascript
8. Write code snippet for managing the size of text area so that it will
not get scrollbar
(with DOM and without DOM)

HTML
----
1. Span vs Div
2. InnerHTML explanation
3. Form tag properties while uploading file
4. Frames vs Iframes
5. W3standards
6. How do you implement Search engine optimization Using HTML

CSS
----
1. #txt and .txt diffences
2. Order of preference for differnt types of CSS(inline,external etc.)
3. How to avoid scrollbar for textarea

Database
---------
1. Explain SQL Query processing
2. Explain Analyze option
3. Getting 10 to 20 records in mysql
4. Query to alter the data type of a field
5. Backup and Restore of Mysql database
6. Mysql 4 vs Mysql 5
7. Normal Forms
8. Employee table(empid, name,deptid, sal)
Query to retrive the details of employees who are having sal more
than the average of their dept sal
9. Inner join Vs Outer Join
10. Unique key vs. Primary key
11. Triggers in Mysql

Linux
------
1. How to monitor currently running processes in linux/unix
2. How to send a process to background[Atleast Three commands]
3. How to change the priority of processes
4. How to see the lists of services running currently
5. How to stop an user to connection to linux with ssh
6. How to reset root password
7. Installing PHP,apache and Database
8. How do you add modules to php(like gdlibrary) in windows and linux
9. How to see the ip address of linux system as normal user
10. what are the tools you use for file upload and ssh connection for linux

Apache
------
1. Virtual hosting
2. How to run apache on 2 or more ports at a time
3. What is directory index
4. How do you control no.of connections to webserver through apache settings
5. What is the default port of apache

Regards
Saikumar

Wednesday, September 12, 2007

PHP Job Opening In hyderabad

Got mail like this

If interested to move to hyderabad, I have a PHP developer postion, send me your resume to the email address ait15@sbcglobal.net"


Thnak you

Sunday, September 9, 2007

Javascript editor to embedd in to webpage also called webeditor

What is TinyMCE?
TinyMCE is a platform independent web based Javascript HTML WYSIWYG editor control released as Open Source under LGPL by Moxiecode Systems AB. It has the ability to convert HTML TEXTAREA fields or other HTML elements to editor instances. TinyMCE is very easy to integrate into other Content Management Systems.

TinyMCE Features

Easy to integrate, takes only two lines of code.
Customizable through themes and plugins.
Customizable XHTML 1.0 output. Block invalid elements and force attributes.
International language support (Language packs)
Multiple browser support, Mozilla, MSIE, FireFox, Opera and Safari (experimental).
PHP/.NET/JSP/Coldfusion GZip compressor, Makes TinyMCE 75% smaller and a lot faster to load.
You can easily use AJAX to save and load content!



for further info on this download everything
Visit this website

Download, Installing WAMP Server on windows XP

if you want to learn php,you need to install wamp server on windows (XP) which hardly takes 5 minutes.but for getting wamp server you need to download

from click here

After downloading click on the exe file you will asked abt simple setings click on finish button your installation will completed


Thank you
BYe

Saturday, September 8, 2007

Install download and configure MYSQL on Windows

Download

click here to download mysql. When this page opens click on "No thanks just take me to download", then pick any mirror site and start downloading MYSQL

Install and Configure

Just click the installer and MYSQL will automatically be installed and configured on your machine using the step by step wizard.

It will ask you a no of settings for the DB installation. Enter according to your requirements but I recommend not to set any passwords ie if you have it for your local use only.

Test

Go to "start" - "all programs". If mysql is installed it will be listed.

select "mysql" - "mysql server 5.0" - "mysql command line client"

It will ask for a password click enter

If everything is fine you will view a welcome message

Friday, September 7, 2007

phpinfo() the power of basics

Just open any editor and type the following:

echo phpinfo( );


Save it as info.php or any other name you like.

This simple page gives you everything you need to know about a web server. This function is also used to test your PHP installation. If you are deep into web development then you can easily recount instances when something is working just fine on the local server but when we upload it everything goes WAMP!.

This is mostly because of different versions of PHP/MYSQL ++ or different settings, configuration. I just need to advice everyone to create a file with phpinfo() on your local server and web hosting server. And in the future when you face an unexpected error just compare the two files and I am telling you than you will relate to me big time.

Thursday, September 6, 2007

PHP Job Opening In hyderabad

Hai i got this mail saying that there are openings in PHP


We are looking for PHP with Mysql programmers for Hyderabad

If you are interested kindly forward your updated profile asap to supriya_d_1984@yahoo.co.in


Regards,
Supriya
IT Recruiter
Hyderabad"

Install and configure PHP5 on windows system

There three major steps involved in installing PHP are:

Downloading PHP Installing PHP Configuring PHP Testing PHP

Before we start you have to understand that there are two possible places where a website can live

A local computer which can be a desktop computer, a laptop++
The internet. A website which is viewed on the "www." internet resides some where with a hosting company.
So to run a website on a personal computer PC you need to install PHP on it. Firstly make sure you have a web server running on your computer. If you are wondering what is a web server and how do you know if it is working or running or what ever on my computer then click here.

Ok now I assume the web server is running. Lets move on with our journey of installing PHP.

Download PHP.

Click here to download PHP 5.2.1 software package from the official site.
Click here to download PHP 5.2.1 installer from the official site. (Automatically installs configure PHP and web server)
Install PHP

Install PHP automatically using an installer

This is a very quick and clean way of installing PHP. It installs and configures PHP and even the web server (IIS, Apache++).

We recommend you take the time to setup PHP yourself as this will provide you with a better understanding of the system, and enables you to install PHP extensions easily when needed.

Install PHP manually

Upgrading from a previous PHP version:

For simplification previous editions of the installation manual suggested moving various ini and DLL files into your SYSTEM (i.e. C:WINDOWS) folder.
We advise you remove all of these files (like php.ini and PHP related DLLs from the Windows SYSTEM folder) before moving on with a new PHP installation.
Be sure to backup these files as you might break the entire system. The old php.ini might be useful in setting up the new PHP as well.
Start Installation

Unzip the PHP 5.2.1 package at C:PHP (ie create a directory call PHP and unload the zip package in it)
Make the C:PHP directory available to the web server, CGI CLI binaries++. (If you don't understand any terms do not worry just move on and do as I say you will have your PHP running in no time)
Right click on "My Computer" which is located on your computer desktop
Go to the "Advanced Tab"
Click on the "Environment Variables" button
Look into the 'System Variables' pane
Find the Path entry (you may need to scroll to find it)
Double click on the Path entry
Enter your PHP directory at the end, including ';' before (e.g. ;C:php)
Press OK and restart your computer
Find the file "php.ini-recommended"in C:PHP. Read it carefully, this file drastically affect the PHP setup. Rename the file to "PHP.ini" and place it in C:windows folder (also known as System folder)
Configure PHP

The next step involves configuring PHP with web server IIS. If you do not know what IIS is and is not installed on your computer Click Here else read on
Click Start -> Control Panel -> Administrative Tools -> Internet Information Systems (IIS)
Double click on "Local Computer" -> Right click "Default Website" - > "Properties" -> "Home Directory"
Change the Execute Permissions to "Scripts only"
Click on the Configuration button, and choose the Application Mappings tab.
Click Add and set the Executable path to the appropriate ISAPI DLL. Example PHP 5 value is: C:phpphp5isapi.dll Supply .php as the extension. Leave "Method exclusions" blank, and check the "Script engine" checkbox. Now, click OK a few times.
Stop IIS completely
Start IIS again
Test PHP

Open notepad or dreamweaver++
Type
Place this file at C:Inetpubwwwroot
Click Start -> Control Panel -> Administrative Tools -> Internet Information Systems (IIS)
Double click on "Local Computer" -> Right click "Default Website" -> "Properties" -> "Documents" -> "Add" -> index.php -> Click "OK"
Open internet explorer or mozilla firefox++ and type http://localhost
If a page opens with PHP details and lot other details then PHP is installed properly configured and ready to rock and roll !!! :) Phew....

Now as you have installed PHP5.2..... (the story doesn't end here, it has just begun ;))

PHP For Dummies

Mr Ajaykumar has written this article for those who are interested in learning about PHP as a scripting language, as well how PHP is rife in today's programming industry.This article is for people who are not aware what PHP is and for those who have not heard of PHP at all. This article will refresh your memory about what PHP is, along with some of the important highlights.

Don’t worry. I am here to tell you, what it is.

What is PHP?

Hi net mates. These days when you surf through some sites, you will find some file extension in the address bar of your browser. Some files extensions like the .htm, .asp, .jsp, .php, and .php3.

You will find this extension .php or the .php3 file extension in some of the popular sites too. Let us see that is this file extension, which language this extension refers to. Let us see what the main high lights of these language.

Hypertext preprocessor is the exact expansion of PHP, tough it doesn’t, fit to the exact spell, and it is adjusted to the word of mouth, called as PHP. PHP is a web scripting language. Let us see some the basic queries, which we come across php.

Who Wrote PHP?

Rasmus wrote PHP. PHP was started off accidentally, Rasmus was designing his web site, and he had planed to put a hit counter for his site. He decided to write a combination of Perl.

There were many enquires about the script which he used. Likewise, it slowly improved on and won the hearts of many programmers.

What type of scripting is PHP client or a server side?

PHP is a server side scripting language; server side scripting language is one, which has the capability of executing the script on the server and serving the output as a HTML File, server side script has the main advantage of interacting with the databases and to perform all types of server manipulations directly. Server side scripting language is responsible for manipulating the data which is filled in the entire web forms, any where in the net.

But this is not the case of a client side script. Some of the client side scripting languages is the JavaScript and VB script, but there are exceptions where, client side script can also be used for server side scripting, which is limited to some extent.

Can I use PHP with HTML?

Sure you can very well use HTML with PHP, like the other scripting languages you can do so. It is not a compulsory act for you to use PHP with the HTML. You can very well get the output with PHP alone. But the expected output, which is exhibited by PHP, is not that attractive for display. By attractive, I mean the formatting done by PHP.

Lets us take an example. You have a server side interaction with the database, which is used to manipulate and fetch a certain type of data based on the query, which is given out. Now, if you are going to display these data using PHP, which is fetched by PHP. The quality of output like the font face, font coloring and display areas are all disturbed, as well as being painful to locate and place the data. If HTML is used to present these data, the outlook of the data exhibited is gorgeous.

Can I Run PHP on the Windows Operating System?

You can very well run PHP on a windows machine. PHP is a cross platform support language, which means, PHP can run on various platforms like the Linux, Windows etc. Your web servers PWS, IIS, Apache can be configured to work PHP.

Is it easy migrating from any other server side scripting languages to PHP?

If you are aware of programming concepts and the application of the logic, then, you will find it ok to code any programming language if you simply understand the syntax. At the same, other scripting languages and PHP, have virtually the same function methodology. The only thing that matters is your requirement, how you are going to apply the logic and code php to your logic.

The main area lies while migrating is the syntax understanding. PHP’s syntax is similar to the C language. People with basic knowledge of C will find it very easy migrating as well as other aspects, an easy task.

I am new to programming, is it easy to learn PHP?

If you are very blind to programming then it is difficult to learn PHP because you may need to learn the programming concepts. This means you require an understanding of the logic, and to be able to troubleshoot the program. If you happen to know at least one programming language, then it is very easy to learn PHP. PHP it is pretty easy compared to other scripting languages.

What are the databases that support PHP?

PHP is very much compatible with MYSQL and POSTGRESQL Databases. PHP also can be programmed to interact with any database right from a simple text file to DB2. It is believed that php interacting with the database has the highest performance, unlike the other scripting languages.

How fast is PHP compared with other scripting languages?

PHP is believed to be fast when compared with other programming languages because of execution speed. In the case of large interactions with the database PHP really plays a good role of execution in performing the interaction. Now, today’s major web sites have been migrating to PHP because of the performance.

PHP is open source. Will this work properly?

PHP is the only scripting language, which has won the hearts of many web servers, has been moving on enormously day-by-day, The main advantages of the open source is that, if there is a problem that particular problem is shared my millions of programmers across the world. But in the case of a licensed version scripting languages, it is very limited to a set of a small community.

As innovative ideas are studied from all the programmers across the world, new ideas are implemented then and there making the language strong.

There is no problem in using PHP, which is open source.

I shall conclude by saying that, all the scripting languages have its own merits and demerits. So, it is up to you to decide for a partial migration or a full migration.

What are the main Advantages of PHP?

Let us see some of the important advantages of PHP. There are a lot of advantages of PHP. When it is compared with other scripting languages, some of the important highlights are as follows.

Speed

PHP is considered to be the fastest, as stated previously, when compared with other programming languages. You can really feel the speed when you are going to, implement live over the web.

Normally when you try to connect a database and fetch certain data, it usually takes time to connect the database, execute the statement, and get the data across. When these operations are performed by PHP it is really faster when compared with other types of scripting languages. Not only for the speed when connecting the database but also while using over other important applications.

Because of its high performance of speed, PHP is being used for some of the important administrations like the server administration over the web, mail functionalities.

Open Source

PHP is open source, open source is one where the user is given a free license to remodel or recode PHP, according to their wish. You might wonder if you can I do these things without source code. Yes would be the answer. Source code is shipped with PHP. It is open source remember.

Multi Platform

PHP supports various platforms, which mean PHP can be installed on almost every operating system, like the window-x, Linux, etc. You may choose the appropriate version and follow the instructions accordingly given in the Manual.

Easy Syntax

PHP syntax is quite easy to code, all the syntax are similar to the C language syntax, If you are very new to the programming environment then it will be a bit difficult task for you to code the PHP.

What are the main disadvantages of PHP?

Every language or scripting language has its own advantages or the disadvantages. Likewise, PHP has some of its own disadvantages.

But these disadvantages can be overcome using advantage methods.

Some people say it is a direct disadvantage, while some people say an indirect disadvantage.

Disadvantage indirectly means some of the aspects and functionalities in PHP, which are not being able to complete using the direct functionality. This particular disadvantage can be overcome using an advantage method.

Let us take a simple example, say redirection. Writing a piece of code from the client side or the server side - in some of the scripting languages there is a single task to achieve this - a single function will do so. But in the case of PHP it is done indirectly.

One more disadvantage is the Error Handling. It is believed that PHP has very poor handling errors qualities. Even this disadvantage can be over come using a feasible advantage solution.

These are some of the disadvantages. Note again, that this disadvantage can be overcome by using the advantage solution.

It is up to you to decide, whether to migrate or learn PHP.

PHP is great in the terms of performance of speed, which is the main factor, which people expect these days.

SRC:http://www.devarticles.com/c/a/PHP/PHP-For-Dummies/1/

Installing PHP under Windows: Further Configuration of WAMP

There are 4 steps involved in doing this configuration

(1)Installing PHP under Windows: Further Configuration of WAMP

In his last article, Matthew showed us how to successfully install and configure WAMP (Windows, Apache, MySQL and PHP) to setup a development environment. In this next piece, learn how to make use of the Apache and PHP configuration files to further enhance your server needs.
In the previous tutorial, your WAMP system on your home PC is best for use as a development server only. You may be able to host a personal home page or hobby page, but of course this would only be available when your computer is on and online. Bearing in mind our decision to only use it as a development server we will have a specialised configuration.

In an attempt to make code developed on our server portable to the widest possible range of configurations, for other peoples’ servers, we will deliberately have a strict configuration, with many options turned off, this will force us to use 'better' programming techniques thus allowing anyone with Apache and PHP to run our code.

First we are going to configure Apache, I will attempt to justify my choices for any configuration changes that I make, as well as briefly explain other possible options. This will allow you to choose your own options should your opinion differ from mine.


2)configure Apache


Installing PHP under Windows: Further Configuration of WAMP - Configuring Apache
(Page 2 of 4 )

To configure Apache the file we will be editing is httpd.conf. Despite the extension this is just an ordinary text file; so open it in notepad for editing either by navigating through the folders (C:Program FilesApache GroupApache2confhttpd.conf) or via the shortcut on the Start menu (Start > All Programs > Apache > Config > Edit httpd Config File).

Apache will treat any lines starting with a hash, or pound, sign (#) as comments, and will ignore them, so a good way to test a setting would be to comment out the old line with a '#' and type your new setting. That way if you make any mistakes it will be nice and easy to go back to the way things were (delete the new line and uncomment the old one.) There will be many lines commented out, much of it will be text explaining various bits and pieces to you, you should read the first few paragraphs (before Section 1). This should explain a couple of points about directory paths, and different slashes. If there is something you don't understand, don't worry as I will be taking you through it all. Remember if you mess up big time the default configuration settings are stored in a backup file (httpd.default.conf). If there are any lines that I don't talk about, don't change them unless you know what you are doing. Finally remember, none of these changes will be apparent until Apache is restarted.
I would recommend changing one line at a time, saving the file and testing it by clicking start > All Programs > Apache > Configure > Test Configuration. If you briefly see a DOS (Command Line) box that disappears, then everything is ok. If the box stays it will tell you where it found an error.

Let’s move on to the various directives (configurations/options).

Line: Listen 80

This tells Apache which port to listen for requests on. The default is port 80. If you change the port from default, for example to 8080 or 8008 (both common choices), then any URLs must be validated (e.g. http://www.localhost:8080/ or http://localhost:8080/test.php). As you could imagine typing this for every URL would get quite annoying, quite quickly, so unless you have a real reason to change it, such as IIS compatibility issues, don't.

Line: LoadModule

The Various LoadModule commands tell Apache to load various external modules. Don't touch these unless you know what you are doing, If you remember when we first installed WAMP in the first tutorial, we added a LoadModule line for PHP (LoadModule php4_module php4apache2.dll). That's because PHP is an external module that Apache needs to load for PHP scripts to work. Move the PHP LoadModule line from the end of the file, where you put it on install, to the end of the LoadModule block.

Line: ServerAdmin

Make sure the email address you wish to be contacted on is here. Should any error page crop up this will allow people to contact you.. This is not really a major issue on a development server, however, should anything go wrong this would let people know who the server belongs to.

Line: ServerName :

localhost:80 will do for this one; for similar reasons to ServerAdmin.

Line: DocumentRoot

This tells Apache where your web documents are stored. You can leave this as is, or change it to something you prefer (c:webdocs might be quicker to browse to than C:/Program Files/Apache Group/Apache2/htdocs). Whatever you do, make sure the directory exists and that you copy all your files to it.

Line: AddType

Back when you installed PHP and added the LoadModule line you should have also added an AddType (AddType application/x-httpd-php .php) line. AddType tells Apache which extensions to associate with which types of documents. Move the PHP AddType line from the bottom of the file to the bottom of the AddType block. If you wish you could change the PHP AddType line to something like (AddType application/x-httpd-php .php .htm). This will associate .htm file types with PHP, so you can include some php scripts in htm files.

We will be adding another AddType line (AddType application/x-httpd-php-source .phps). This line will make the extension .phps a PHP Source file, which will display the PHP code with special coloured formatting (once we turn script highlighting on in PHP). You will probably find this quite useful for debugging.

Line: ErrorDocument

These allow you to create your own documents to handle errors. For instance, if a page is missing you usually get an ugly page with a message similar to '404 Not Found'. Well, you can make your own error pages. This will be more fully covered in a future tutorial; however, for the moment uncomment the line ('# ErrorDocument 404 /error/HTTP_NOT_FOUND.html.var') by removing the '#' and change the .html.var extension to .html. In your document folder create a new directory called 'error' then create an html page called HTTP_NOT_FOUND. This page should contain a message telling the user that the page they clicked on could not be found. You should also include a link to your main page. Now, after Apache is restarted, whenever you go to a page that doesn't exist (http://localhost/bad/page) you will get your own pretty error page instead of the standard ugly one.

That's about all you have to worry about for Apache. As I said before, I recommend that you change one setting at a time, test the configuration (Start > All Programs > Apache > Configure > Test Config), and, if the black screen disappears, fine, if it stays, take note of any errors and correct whatever you may have done wrong. Remember that no changes will take effect until Apache has been restarted (Start > All Programs > Apache > Control > Restart).


3)PHP
(Page 3 of 4 )

Now we are going to edit php.ini in the Apache folder (one up from the conf folder). Anything following the semi-colon character (;) is commented out, to uncomment it, simply delete the semi-colon.

short_open_tag = On
This should be set to off. This will not allow us to use the short style tags. Although there are ways to get around this, this setting will force us to code in the 'proper' and more portable way ().

asp_tags = Off
Who wants to use ASP style <% %> tags (apart from ASP developers)?

highlight.string = #DD0000
highlight.comment = #FF9900
highlight.keyword = #007700
highlight.bg = #FFFFFF
highlight.default = #0000BB
highlight.html = #000000

Simply uncomment these lines (remove the semi colon (;) before them).

error_reporting = E_ALL
Sets PHP to tell us about all errors.

display_errors = On
PHP tells us about errors rather that just sit there with a blank screen!

register_globals = Off
Stops many possible security issues, and forces the user of the superglobal arrays (ie: $_POST, $_GET, $_COOKIES, etc.).

doc_root = C:Program FilesApache GroupApache2htdocs
This path should be the same as the document root you set in Apache’s httpd.conf file.

;extension= ...
This allows you to include various PHP extensions, a bit like modules in Apache. You should only turn then on when you need them.

session.save_handler = files
Make sure that this is set to files.

session.save_path = c:/temp
Make sure that this is set to a temp directory that exists on your PC. It will be used to save data for sessions.


Installing PHP under Windows: Further Configuration of WAMP - Conclusion
(Page 4 of 4 )



That's about it, save the file and restart Apache. View the test.php file you wrote in Installing PHP Under Windows to check that everything is still functioning the way it should be. In this article, we’ve covered various aspects of the Apache and PHP configuration files. By making use of the tips above, you are bettering the chance of creating portable code that can be used across an array of system configurations

Monday, September 3, 2007

G.D installation on Windows in PHP

Go to http://www.php.net/downloads.php and download the 'PHP 4.x.x zip package' if you don't allready have it. This package contains the GD-Library for windows. Find php_gd2.dll (or php_gd.dll if you need gif-support, but you will have less good image quality) and put it in your php folder (Usual c:\php). Find in the php.ini in your windows folder:
;extension=php_gd.dll
;extension=php_gd2.dll

Uncomment extension="php_gd2".dll by deleting the ';' in front of it.

Installing G.D library in PHP On WAMP Server

Installing G.D library in PHP On WAMP Server is very simple.

After installtion of WAMP on Windows XP You can see icon on right side bottom of your desktop.Click on that icon you can see a set of options.From that options
choose PHP Settings->PHP Extensions->PHP_GD2

click on it Restart Wamp Server

Thank you
BYe.

Friday, August 24, 2007

PHP Jobs

Hai

I got this Mail saying that there is a php opening in there company

ravi.kiran from Hyderabad

"We need PHP programmers with CMS, ECommerce, community sites experience. We also need action scripting, CSS, Ajax, Flash, web designing experts. Exp 1-3 years. Send your resumes to hai2ravikiran@yahoo.com"

Thank you

Smarty template engine

Smarty template engine frame work for php which execurtes php scripts faster

for more info see this official website
for smarty

Smarty Info

For Smarty Documentation Download

Documenattaion download


All the best

Wednesday, August 22, 2007

How to create a php upload progress meter

By Justin Silverton
This progess meter is based on the yahoo user interface library and alternative php cache (APC). You will need both of these for it to display properly. PHP 5.2.0 or higher is also required. (I have written a previous article on alternative PHP cache here).
The yahoo user interface library can be found here.
How it works
Once APC is installed and configured, the following needs to be added to your php.ini:
apc.rfc1867 = on
Aside from the Yahoo libraries, this is what makes the progress meter possible using php.
This is called the File Upload Progress hook handler and it is only availableif you compiled APC against PHP 5.2.0 or later. When enabledany file uploads which includes a field called APC_UPLOAD_PROGRESS before the file field in an upload formwill cause APC to automatically create an upload_user cache entry where is the value of the APC_UPLOAD_PROGRESS form entry













Download
Demo can be found here

Source can be found here



How to install Alternative PHP Cache





By Justin Silverton
What is APC cache?
The Alternative PHP Cache (APC) is a free and open opcode cache for PHP. It was conceived of to provide a free, open, and robust framework for caching and optimizing PHP intermediate code.
Installing
APC Cache is not included with the latest release of php (although it is planned on being included with version 6). It says on the main PHP website that the .dlls can be downloaded from the pecl extensions package, but after downloading and extracting it, I realized that it is not there. I have found the correct .dlls and other files that are needed and they can be download from my server here.
After downloading and extracting the above zip file, complete the following steps:
1) copy the proper php_apc.dll (depending on your version) into your php extensions directory
2) add the following to your php.ini: extension=php_apc.dll (this should be placed under the other extension lines)
3) add the following to your php.ini:
apc.shm_segments=1apc.optimization=0apc.shm_size=128apc.ttl=7200apc.user_ttl=7200apc.num_files_hint=1024apc.mmap_file_mask=/tmp/apc.XXXXXXapc.enable_cli=1
Note: APC needs a temp path to exist, and be writable by the web server. It checks TMP, TEMP, USERPROFILE environment variables in that order and finally tries the WINDOWS directory if none of those are set.
4) copy apc.php (included with the .zip file) to directory on your web server and launch it.
You should see the following:















APC Cache options
Here is some more information about the various options that can be used to setup apc cache.
apc.enabled This can be set to 0 to disable APC. This is primarily useful when APC is statically compiled into PHP, since there is no other way to disable it (when compiled as a DSO, the zend_extension line can just be commented-out). (Default: 1)
apc.shm_segments The number of shared memory segments to allocate for the compiler cache. If APC is running out of shared memory but you have already set apc.shm_size as high as your system allows, you can try raising this value. (Default: 1)
apc.shm_size The size of each shared memory segment in MB. By default, some systems (including most BSD variants) have very low limits on the size of a shared memory segment. (Default: 30)
apc.optimization The optimization level. Zero disables the optimizer, and higher values use more aggressive optimizations. Expect very modest speed improvements. This is experimental. (Default: 0)
apc.num_files_hint A “hint” about the number of distinct source files that will be included or requested on your web server. Set to zero or omit if you’re not sure; this setting is mainly useful for sites that have many thousands of source files. (Default: 1000)
apc.ttl The number of seconds a cache entry is allowed to idle in a slot in case this cache entry slot is needed by another entry. Leaving this at zero means that your cache could potentially fill up with stale entries while newer entries won’t be cached. (Default: 0)
apc.user_ttl The number of seconds a user cache entry is allowed to idle in a slot in case this cache entry slot is needed by another entry. Leaving this at zero means that your cache could potentially fill up with stale entries while newer entries won’t be cached. (Default: 0)
apc.gc_ttl The number of seconds that a cache entry may remain on the garbage-collection list. This value provides a failsafe in the event that a server process dies while executing a cached source file; if that source file is modified, the memory allocated for the old version will not be reclaimed until this TTL reached. Set to zero to disable this feature. (Default: 3600)
apc.filters A comma-separated list of POSIX extended regular expressions. If any pattern matches the source filename, the file will not be cached. Note that the filename used for matching is the one passed to include/require, not the absolute path. If the first character of the expression is a + then the expression will be additive in the sense that any files matched by the expression will be cached, and if the first character is a - then anything matched will not be cached. The - case is the default, so it can be left off. (Default: “”)
apc.enable_cli Mostly for testing and debugging. Setting this enables APC for the CLI version of PHP. Normally you wouldn’t want to create, populate and tear down the APC cache on every CLI request, but for various test scenarios it is handy to be able to enable APC for the CLI version of APC easily. (Default: 0)
apc.max_file_size Prevents large files from being cached. (Default: 1M)
apc.stat Whether to stat the main script file and the fullpath includes. If you turn this off you will need to restart your server in order to update scripts. (Default: 1)
apc.write_lock On busy servers when you first start up the server, or when many files are modified, you can end up with all your processes trying to compile and cache the same files. With write_lock enabled, only one process at a time will try to compile an uncached script while the other processes will run uncached instead of sitting around waiting on a lock. (Default: 1)
apc.rfc1867 RFC1867 File Upload Progress hook handler is only available if you compiled APC against PHP 5.2.0 or later. When enabled any file uploads which includes a field called APC_UPLOAD_PROGRESS before the file field in an upload form will cause APC to automatically create an upload_ user cache entry where is the value of the APC_UPLOAD_PROGRESS form entry. (Default: 0)
The offical PHP manual page can be found

SRC:http://www.whenpenguinsattack.com/category/php/page/7/

Monday, August 20, 2007

PHP MSSQL connecting script and function

WE can connect to MSSQL database by using PHP. To connect to MsSQL we have to enable the MsSQL extension support inside php.ini file. For this we have to uncomment the line saying
extension=php_mssql.dll The status of the MSSQL support can be checked by using phpinfo function.
To check the PHP support for MSSQL we can use the function phpinfo(). To enable MSSQL support we have to uncomment the this line inside php.ini file. extension=php_mssql.dll If the support exists then you will get the details like this below.



Once the support is available we can use different functions to handle data from MSSQL database. Now let us try for connecting to MSSQL database server. Here are the connection steps. Note that we have used one remote db server but same string will work for a local server also.
$dbusername='username';
$dbpassword='password';
$servername='servername';
$link = mssql_connect ($servername,$dbusername,$dbpassword);

Saturday, August 18, 2007

PHP Script Execution Time

You may have seen this feature of some sites around the net. Time execution basically means you can see how long it took for the page to load. This can be helpful when programming, or whenever.
An example of this script:Script Execution Time: 0.001 seconds
Lets say you have a basic HTML page: Just some text Just some text Just some text Just some text Just some text Just some text Just some text Just some text Just some text Just some text Just some text Just some text Just some text Just some text Just some text
So we'll add the time execution script here.
The basic logic behind this is we need to see at what time the script started, and when it ended. After that we just need to find the difference between those two numbers.
To refresh your memory on how time and dates on the internet work, please check out, Playing with Dates.
Instead of using the common mktime() function to get the current timestamp, we'll use the following function to get the micro time. This is because usual execution times are much less then 1 second, so we'll need to use this for more accurate times.
The function we will be using to get the current micro time is this:




?>

That's about it, now you can see how long it takes to load the page.

 
eXTReMe Tracker