Showing posts with label PHP. Show all posts
Showing posts with label PHP. Show all posts

Thursday, February 12, 2009

Session Funcions in Php

session.name string
session.name specifies the name of the session which is used as cookie name. It should only contain alphanumeric characters. Defaults to PHPSESSID. See also session_name().

session.auto_start boolean
session.auto_start specifies whether the session module starts a session automatically on request startup. Defaults to 0 (disabled).

session.serialize_handler string
session.serialize_handler defines the name of the handler which is used to serialize/deserialize data. Currently, a PHP internal format (name php) and WDDX is supported (name wddx). WDDX is only available, if PHP is compiled with WDDX support. Defaults to php.

session.gc_probability integer
session.gc_probability specifies the probability that the gc (garbage collection) routine is started on each request in percent. Defaults to 1.

session.gc_maxlifetime integer
session.gc_maxlifetime specifies the number of seconds after which data will be seen as 'garbage' and cleaned up.

Note: If you are using the default file-based session handler, your filesystem must keep track of access times (atime). Windows FAT does not so you will have to come up with another way to handle garbage collecting your session if you are stuck with a FAT filesystem or any other fs where atime tracking is not available.

session.referer_check string
session.referer_check contains the substring you want to check each HTTP Referer for. If the Referer was sent by the client and the substring was not found, the embedded session id will be marked as invalid. Defaults to the empty string.

session.entropy_file string
session.entropy_file gives a path to an external resource (file) which will be used as an additional entropy source in the session id creation process. Examples are /dev/random or /dev/urandom which are available on many Unix systems.

session.entropy_length integer
session.entropy_length specifies the number of bytes which will be read from the file specified above. Defaults to 0 (disabled).

session.use_cookies boolean
session.use_cookies specifies whether the module will use cookies to store the session id on the client side. Defaults to 1 (enabled).

session.use_only_cookies boolean
session.use_only_cookies specifies whether the module will only use cookies to store the session id on the client side. Defaults to 0 (disabled, for backward compatibility). Enabling this setting prevents attacks involved passing session ids in URLs. This setting was added in PHP 4.3.0.

session.cookie_lifetime integer
session.cookie_lifetime specifies the lifetime of the cookie in seconds which is sent to the browser. The value 0 means "until the browser is closed." Defaults to 0.See also session_get_cookie_params() and session_set_cookie_params().

session.cookie_path string
session.cookie_path specifies path to set in session_cookie. Defaults to /.See also session_get_cookie_params() and session_set_cookie_params().

session.cookie_domain string
session.cookie_domain specifies the domain to set in session_cookie. Default is none at all. See also session_get_cookie_params() and session_set_cookie_params().

session.cookie_secure boolean
session.cookie_secure specifies whether cookies should only be sent over secure connections. Defaults to off. This setting was added in PHP 4.0.4. See also session_get_cookie_params() and session_set_cookie_params().

session.cache_limiter string
session.cache_limiter specifies cache control method to use for session pages (none/nocache/private/private_no_expire/public). Defaults to nocache. See also session_cache_limiter().

session.cache_expire integer
session.cache_expire specifies time-to-live for cached session pages in minutes, this has no effect for nocache limiter. Defaults to 180. See also session_cache_expire().

session.use_trans_sid boolean
session.use_trans_sid whether transparent sid support is enabled or not. Defaults to 0 (disabled).

Php Regular Expression

ereg ("abc", $string);
/* Returns true if"abc"
is found anywhere in $string. */

ereg ("^abc", $string);
/* Returns true if "abc";
is found at the beginning of $string. */

ereg ("abc$", $string);
/* Returns true if "abc"
is found at the end of $string. */

eregi ("(ozilla.[23]|MSIE.3)", $HTTP_USER_AGENT);
/* Returns true if client browser
is Netscape 2, 3 or MSIE 3. */

ereg ("([[:alnum:]]+) ([[:alnum:]]+) ([[:alnum:]]+)", $string,$regs);
/* Places three space separated words
into $regs[1], $regs[2] and $regs[3]. */

$string = ereg_replace ("^", "
", $string);
/* Put a
tag at the beginning of $string. */

$string = ereg_replace ("$", "
", $string);
/* Put a
; tag at the end of $string. */

$string = ereg_replace ("\n", "", $string);
/* Get rid of any newline
characters in $string. */

Sunday, February 1, 2009

Procedure to Configure Php with apache on windows

Installing PHP Files on Windows

Unlike building and installing PHP on Linux/Unix, installing PHP on Windows requires nothing more than downloading the distribution and moving a few files around. To download the PHP distribution files, go to the home of PHP, http://www.php.net/, and follow the link to the Downloads section. Grab the latest version of the zip package from the Windows Binaries section—for this example we are using 4.2.3. Your distribution will be named something similar to php-version.zip, where version is the most recent release number.

Once the file is downloaded to your system, double-click on it to launch your unzipper. The distribution is packed up with pathnames already in place, so if you extract the files to the root of your drive, it will create a directory called php-version-Win32, and place all the files and subdirectories under that new directory.

Now that you have all the basic PHP distribution files, you just need to move a few of them around:

  1. In the PHP installation directory, find the php.ini-dist file and rename it php.ini.

  2. Move the php.ini file to C:\WINDOWS\ or wherever you usually put your *.ini files.

  3. Move the php4ts.dll file to C:\WINDOWS\SYSTEM\ or wherever you usually put your *.dll files.

To get a basic version of PHP working with Apache, you'll need to make a few minor modifications to the Apache configuration file.

Integrating PHP with Apache on Windows

To ensure that PHP and Apache get along with one another, you need to add a few items to the httpd.conf configuration file. First, find a section that looks like this:

# Example: # LoadModule foo_module modules/mod_foo.so # LoadModule access_module modules/mod_access.so LoadModule actions_module modules/mod_actions.so LoadModule alias_module modules/mod_alias.so LoadModule asis_module modules/mod_asis.so LoadModule auth_module modules/mod_auth.so #LoadModule auth_anon_module modules/mod_auth_anon.so #LoadModule auth_dbm_module modules/mod_auth_dbm.so #LoadModule auth_digest_module modules/mod_auth_digest.so LoadModule autoindex_module modules/mod_autoindex.so #LoadModule cern_meta_module modules/mod_cern_meta.so LoadModule cgi_module modules/mod_cgi.so #LoadModule dav_module modules/mod_dav.so #LoadModule dav_fs_module modules/mod_dav_fs.so LoadModule dir_module modules/mod_dir.so LoadModule env_module modules/mod_env.so #LoadModule expires_module modules/mod_expires.so #LoadModule file_cache_module modules/mod_file_cache.so #LoadModule headers_module modules/mod_headers.so 

At the end of this section, add the following:

LoadModule php4_module c:/php-version/sapi/php4apache2.dll 

Next, look for this section:

# # AddType allows you to add to or override the MIME configuration # file mime.types for specific file types. # 

Add the following lines:

AddType application/x-httpd-php .php .phtml .html AddType application/x-httpd-php-source .phps 

This ensures that the PHP engine will parse files that end with the .php, .phtml, and .html extensions. Your selection of filenames may differ, and you may wish to add .php3 as an extension, for backwards compatibility with any very old scripts you may have.

Any files with the .phps extension will be output as PHP source. That is, the source code will be converted to HTML and color-coded. This can be useful for debugging your scripts.

Save this file, and then restart Apache. If the server starts, PHP is now part of the Apache Web server.

Wednesday, January 28, 2009

Explode function to divide string

This will show explode function .
it will divide the string into number of chunks


$someWords = "Please don't blow me to pieces.";

$wordChunks = explode(" ", $someWords);
for($i = 0; $i < count($wordChunks); $i++){ echo "Piece $i = $wordChunks[$i]
";
}

$wordChunksLimited = explode(" ", $someWords, 4);
for($i = 0; $i < count($wordChunksLimited); $i++){ echo "Limited Piece $i = $wordChunksLimited[$i]
";
}

Monday, January 5, 2009

Important PHP Website

PHP.net: A Tourist's Guide

Everyone knows the www.php.net site. All of us went there sooner or later, and will keep going back there. This is the central reference point for PHP users, and there is a wealth of information there. Not all of it is obvious. Come with me, I'll show you.

www.php.net: Main Website

This is the primary web site. The front page is where major news is published: new PHP versions, security updates, and new projects launched. This site is also mirrored in dozens of countries worldwide.

This is the home of the download page, for everyone to get the latest version of the PHP source code and binaries for Windows. The current and next-to-current versions are available there. (There is also a PHP Museum, which has all of the source distributions since June 1996.)

The next most visited section is the documentation. The documentation is translated into twelve different languages, and is available in a variety of different formats. Users are able to read notes on the documentation left by other users, and contribute their own notes. The documentation is a real community project by itself!

The support page has all the directions to a wealth of resources both inside and outside of PHP.net. The community has built a huge network of knowledge bases, PHP user groups, and training sessions where anyone can have his or her questions answered. Non-English-speaking users also get a large share of attention.

Now, buckle up your seat belt, and stop smoking. Here are the no-light streets:

talks.php.net: Conference Materials

This is where speakers at various PHP-related conferences keep their slides. It covers all sorts of topics, from the famous 'Rasmus' introduction to PHP to the latest 'PHP system administration', through PEAR and advanced topics. All those slides are available within the PHP slide application.

news.php.net: Mailing Lists Web and NNTP Interface

news.php.net is the web interface to the PHP mailing lists. If you're not subscribed to the mailing lists, but you still want to keep in touch regularly, this is your place. An infinite pile of fresh news and trends of PHP. You can also point your news reader at the NNTP server at news.php.net to follow the lists.

pear.php.net: The PHP Extension and Application Repository

PEAR is the next revolution in PHP. This repository is bringing higher level programming to PHP. PEAR is a framework and distribution system for reusable PHP components. It eases installation by bringing an automated wizard, and packing the strength and experience of PHP users into a nicely organised OOP library.

pecl.php.net: The PHP Extension Community Library

PECL is a repository for PHP Extensions, providing a directory of all known extensions and hosting facilities for downloading and development of PHP extensions.
The packaging and distribution system used by PECL is shared with its sister, PEAR.

bugs.php.net: Bug Database

The bug database is where you can bring problems with PHP to the attention of developers (but don't forget to double-check that somebody else hasn't already reported the same problem!).

doc.php.net: Documentation collaboration

The documentation projects website tries to gather all PHP.net hosted documentation teams together with tools, status reports and an RFC system.

docs.php.net: Documentation dev server

The documentation developmental server is a PHP mirror that contains upcoming releases of the PHP documentation before it's pushed out to the mirrors. Documentation changes, such as layout, is tested here (with feedback requested) before being made official. Documentation is built here four times a day.

qa.php.net: Quality Assurance Team

The Quality Assurance team is one of the most important pieces of the PHP project, protecting users from bugs. It is gathered around the QA mailing list, and this site allows anyone to provide tests and experience to the release process.

cvs.php.net: CVS Repository

The PHP project is organized with a CVS server, and this website is the web interface to it. There you can browse the history (and latest versions) of the source code for all of the PHP projects. For example, the php-src module is the repository for the source code to the latest version of PHP itself.

lxr.php.net: Cross Reference

Cross reference for source code, based on the "Linux Cross Reference". This is the ultimate tool for exploring PHP code. Any time an important macro or function is detected within the code, it is linked to its definition, and all its usage locations. This will help you build your code, and understand the PHP source.

gtk.php.net: PHP-GTK

This web site is the home of the PHP-GTK project, which allows PHP to be used to build graphical interfaces, with slick interface and highly interactive content. You'll find the downloads and docs here, and the latest news from the project.

snaps.php.net: Daily PHP Snapshots

This is your first stop if you're looking for cutting edge development versions of PHP which are generated every day from the current stable and current development sources.

gcov.php.net: Test and Code Coverage analysis

This site is dedicated to automatic PHP code coverage testing. On a regular basis current CVS snapshots are being build and tested on this machine. After all tests are done the results are visualized along with a code coverage analysis.

wiki.php.net: The PHP Wiki

Home of the official PHP wiki, this site contains information related to php.net like RFCs, GSOC information, and TODO files. Most every aspect of the PHP project has a wiki section and everyone is able to apply for wiki commit access.