How to install zend framework
8 Easy steps to install zend frame work.
1. Download latest version of Zend Frame work.
http://downloads.zend.com/framework/1.11.11/ZendFramework-1.11.11.zip
2. Download “Zend Frame work Quick start”
http://framework.zend.com/demos/ZendFrameworkQuickstart.zip
3. Create directory under your development environment.
C: /wamp/www/first_zend_application
4. Copy all the folders/files from the “Zend Frame work Quick start” and put under “first_zend_application”
5. Copy the “Zend” folder under “library” from the Zend framework and put this under “library” of first_zend_application.
6. Add below line in your apache config file
Listen 8085
<VirtualHost *:8085>
DocumentRoot "c:/wamp/www/ first_zend_application /public/"
</VirtualHost>
7. To connect with MySQL, put below code in your application.ini file
resources.db.adapter = "PDO_MYSQL"
resources.db.params.host = "localhost"
resources.db.params.dbname = "we"
resources.db.params.username = "root"
resources.db.params.password = "xxxxxx"
8. Finally Zend frame work installed. Run http://localhost:8085/ in your browser
php remove first <p> and last </p> tags from string
1 2 3 4 5 6 7 8 9
$string = "<p>text text<br>text<p>text</p></p>"; $pattern = "=^<p>(.*)</p>$=i"; echo preg_match($pattern, $string, $matches). "<br />" ; var_dump($matches);
Output:
1 2 3 4 5 6 7 8 9 10 11 12 13
1 <br />
array(2) {
[0]=>
string(35) "<p>text text<br>text<p>text</p></p>"
[1]=>
string(28) "text text<br>text<p>text</p>"
}
Explain abstract class and its behaviour?
An abstract class defines the basic skeleton for the class. It contains attributes and members but some members are incomplete and is waiting for some other class to extend it through inheritance so that the derived class provides a full functionality for the incomplete methods.
A abstract class cannot be instantiated and it can only be extended. A class prefix with “abstract” keywords are abstract class.
If a method is defined as abstract then it cannot be declared as private (it can only be public or protected).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
abstract class classname
{
//attributes and methods
.
.
abstract function methodname
}
class derived extends classname
{
function methodname
}
/*Example*/
empname = $empname;
$this->empage = $empage;
}
abstract function outputData();
}
class EmployeeData extends employee //extending abstract class
{
function __construct($name,$age)
{
$this->setdata($name,$age);
}
function outputData()
{
echo $this->empname;
echo $this->empage;
}
}
$a = new EmployeeData("Saurabh","24");
$a->outputData();
/*Output*/
Saurabh
24
?>
?>
Installing Zend Framework on WAMP
Generally we are facing some difficulties to setup Zend Framework environment on WAMP.
Suppose WAMP installed on C drive (C:/wamp)
There are some basic requirements for setup:
1: Php version should be greater than PHP 5.2.x
2: Load mod_rewrite Rule: Web Server (Apache) supports mod_rewrite rule to support .htaccess file. so to load this module, in Apache folder there is httpd.conf file (C:/wamp/bin/apache/Apache2.2.11/conf/)
#LoadModule rewrite_module modules/mod_rewrite.so
3: Download Framework: Download ZendFramework archive. It can be download from http://framework.zend.com/download/ in a .zip or .tar.gz format and extract it.
4: Setting Up Zend Tool: Create a new directory on Programe Files named as “ZendCli” and paste library and bin folder to this directory extracted from ZendFramework archive.
5: Add the bin directory to Environment variable: On computer properties advance options there is PATH variable.
Add ;C:\Program Files\ ZendCli \bin
To execute php on CLI (Command Line Interpreter) mode, add php to environment variable
;C:/wamp/bin/php/php5.2.8/bin
Now Reboot the System to set all environment variables.
6: Testing Zend: To test your installation open a command prompt and type
zf show version
if all work fine, your should see
Zend Framework Version: 1.10.0
If not, then check all the path and bin directory, once zf tool is working. We have all zf command available and can start working on Zend framework.
7: Now open a command prompt, traverse to your root directory and type
zf create project zfPrj
this command will create a directory structure for working on framework as shown in figure below:
This figure illustrates the structure of Zend framework. application directory is where the source code is available, public folder is where the website executes.
8: The last work is to copy the library/zend/ directory from Zend archive to our application zfPrj/library. After doing this browse this URL http://localhost/zfPrj /public/

Outlook Appointment / iCal file using PHP
Using a simple code we can create outlook appointment or iCal files using PHP.
Below are the source code :
$ical = "BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//hacksw/handcal//NONSGML v1.0//EN
BEGIN:VEVENT
UID:" . md5(uniqid(mt_rand(), true)) . "@yourhost.test
DTSTAMP:" . gmdate('Ymd').'T'. gmdate('His') . "Z
DTSTART:19970714T170000Z
DTEND:19970715T035959Z
SUMMARY:Bastille Day Party
END:VEVENT
END:VCALENDAR";
//set correct content-type-header
header('Content-type: text/calendar; charset=utf-8');
header('Content-Disposition: inline; filename=calendar.ics');
echo $ical;
exit;
