Thursday, May 20, 2010

Enable htaccess on Apache

.htaccess files allows us to change configurations on our servers per directory or subdirectory. we may enable htaccess files by editing our httpd.conf rewmoving the comment on line from

;LoadModule rewrite_module modules/mod_rewrite.so

to

LoadModule rewrite_module modules/mod_rewrite.so

we need to change the AllowOverride directive also from

<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Satisfy all
</Directory>

to

<Directory />
Options FollowSymLinks
AllowOverride All
Order deny,allow
Deny from all
Satisfy all
</Directory>

You can also rename your .htaccess file by adding the line below on you httpd.conf file

AccessFileName [filename]
example: AccessFileName .configuration


Monday, May 17, 2010

Zend PHP-5 Certification

Hi all,

I am quite happy to let you all know that I got certified by Zend

I think the following will be helpful to you.

Please go through the Davids blog        

http://readtheweb.info/2008/01/02/passing-the-zend-php-5-certification-exam/


Wednesday, May 12, 2010

What is .htaccess?

Introduction to .htaccess..

This work in constant progress is some collected wisdom, stuff I've learned on the topic of .htaccess hacking, commands I've used successfully in the past, on a variety of server setups, and in most cases still do. You may have to tweak the examples some to get the desired result, though, and a reliable test server is a powerful ally, preferably one with a very similar setup to your "live" server. Okay, to begin.. 

.htaccess files are invisible

There's a good reason why you won't see .htaccess files on the web; almost every web server in the world is configured to ignore them, by default. Same goes for most operating systems. Mainly it's the dot "." at the start, you see?

If you don't  see, you'll need to disable your operating system's invisible file functions, or use a text editor that allows you to open hidden files, something like bbedit on the Mac platform. On windows, showing invisibles in explorer should allow any text editor to open them, and most decent editors to save them too**. Linux dudes know how to find them without any help from me.

 

Tuesday, April 27, 2010

Using PHP Dom to manipulate XML

PHP5 provides easy functions to access and manipulate xml.
SimpleXML and DOM.

SimpleXML sacrifices so many functionalities for simplicity.
This is a trade-off for the power and flexibility it provides.
You cannot remove and manipulate elements using simplexml directly.
But we can do the same using DOM. Also we can export simplexml objects to dom
and do the required modification. This is a pretty good feature.

Loading and Saving XML Documents:

There are two ways for loading xml documents.
First by loading from a file and second from string.

From File :

// PHP Script
<?php
$dom = new DOMDocument();
$dom->load("library.xml");
echo $dom->saveXML();
?>

//XML - Create a file library.xml and paste the following xml to it.

<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>

From string

// PHP Script
<?php
$xml = <<<XML
<?xml version="1.0" encoding="ISO-8859-1"?>
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
XML;
?>

Saturday, March 27, 2010

Extracting username from email address

Usually we extract username using a combination of functions. Let me show you the example.

1. Using substr_replace() and strpos:
<?php
$email = 'vijithbk@gmail.com';
echo substr_replace($email, "", strpos($email, "@"));
?>
// Output
vijithbk

2. Using strstr => this is available php 5.3.1+
<?php
$email = 'vijithbk@gmail.com';
echo strstr($email,"@",true);
?>
// Output
vijithbk

Is that simple??
if you have got some other simple methods dnt forget to post it as comments

Sunday, September 16, 2007

php strtok( ) function

Hi, its been a lot of time I have been working in php. Although i had been using this function for a long time I was quite unaware about its importance. This made me put a post about this nice function.

strtok() splits a string into smaller strings usually called as tokens, with each token being delimited by any character from token. That is, if you have a string like "This is vijithbk" you could tokenize this string into its small words by using the space character as the token.


$string = "This is vijith";

$tok = strtok($string, " ");

while (
$tok !== false)
{
echo
"Word=$tok \n";
$tok = strtok(" ");
}
//Output

Word=This Word=is Word=vijith