• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Php
 

Php

on

  • 23,351 views

Learn PHP basics

Learn PHP basics

Statistics

Views

Total Views
23,351
Views on SlideShare
23,343
Embed Views
8

Actions

Likes
4
Downloads
215
Comments
1

3 Embeds 8

http://www.slideshare.net 3
http://localhost 3
http://test.idoc.vn 2

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

CC Attribution-ShareAlike LicenseCC Attribution-ShareAlike License

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel

11 of 1 previous next

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
  • Useful slides
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Php Php Presentation Transcript

    • PHP Server Side Scripting Language www.php.net
    • What is the other side?
      • JavaScript is the client side scripting language
      • JavaScript is integrated within your browser
      • It helps you do things on the user’s computer for e.g. form validation, simple calculation etc.
    • Why is PHP so powerful?
      • Open Source and cross-platform
      • especially lightweight and speedy
      • can send HTTP headers
        • set cookies
        • manage authentication
        • and redirect users
      • excellent connectivity to many databases
      • integration with various external libraries
        • to let you generate PDF documents
        • parse XML
        • create and modify images on the fly
      • no need for a special development environment or IDE
        • You start a block of PHP code with <?php and end it with ?>
        • PHP goes right into your Web pages
      • You don't have to declare variables before you use them
      • it's easy to create arrays and hashes (associative arrays)
      • A good rule of thumb for PHP: &quot;When in doubt, try it; it will probably work.&quot;
    • PHP history
      • In 1995, when Rasmus Lerdorf started what was to become PHP, the only goal he had in mind was to find out who was reading his resume.
      • Rasmus Lerdorf's original concept of creating tags within the HTML text for calling C code is revolutionizing the way dynamic Web applications are created.
      • Though the code written by him has been revised and the scripting engine re-written from scratch. Still, the concepts and the inspiration for PHP came from Lerdorf's approach of finding practical and dynamic solutions that Web developers could use in their day-to-day work.
    • PHP Server Side Scripting language Dynamic Web Pages Mail Cookies DataBase Support
    • PHP Basics
      • PHP means PHP: Hypertext Preprocessor
      • Escaping from HTML <?php . . . ?>
      • Statements You use the semi-colon (;) at the end of the line
      • Comments PHP supports, C, C++ style comments. /* C, C++ style multi-line comment */
    • Basic Syntax
      • <?php echo &quot;Hello, World!&quot;; ?> produces Hello, World!
      • Variables are marked with a preceding $. You could write &quot;Hello, World!&quot; like this: <?php $message = &quot;Hello, World!&quot;; echo $message; ?>
      • String concatenation is done with . (a period)
      • other arithmetic operators are what you would expect: <?php $greeting = &quot;Hello &quot;; $num = 3 + 2; $num++; echo &quot;$greeting $num people!&quot;; ?> produces Hello 6 people!
    • Single and double quote
      • Just as in Perl, a string surrounded with double quotes causes variables inside it to be interpolated, but a string surrounded with single quotes does not. So,
      • <?php $name = “Shantanu”; $greeting_1 = &quot;Hello, $name!&quot;; $greeting_2 = 'Hello, $name!'; echo &quot;$greeting_1 &quot;; echo &quot;$greeting_2 &quot;; ?>
        • produces
        • Hello, Shantanu! Hello, $name!
      • Note that the in the string turns into a new line, just as in Perl or in C. This only works in double-quoted strings, however.
    • Arrays
      • You set off array indices (regular or associative) with square brackets ([ and ]): $fruit[0] = 'banana'; $fruit[1] = 'papaya';
      • A shortcut for creating arrays is the array() $fruit = array('banana','papaya');
      • The built-in function count() tells you how many elements are in an array: $fruit = array('banana','papaya'); print count($fruit); prints 2
    • Arrays
      • Array index starts from 0
      • $a[0] = &quot;first&quot;; // a two element array $a[1] = &quot;second&quot;; $a[] = &quot;third&quot;; // easy way to append to the array. // Now, $a[2] has &quot;third&quot;
      • echo count($a); // prints 3
      • // create a hash in one shot
      • $myphonebook = array (
      • &quot;sbabu&quot; => &quot;5348&quot;,
      • &quot;keith&quot; => &quot;4829&quot;,
      • &quot;carole&quot; => &quot;4533&quot;
      • );
      • // oops, forgot dean! add dean
      • $myphonebook[&quot;dean&quot;] = &quot;5397&quot;;
      • // yeoh! carole's number is not that. correct it!
      • $myphonebook[&quot;carole&quot; => &quot;4522&quot;
      • // didn't we tell that hashes and arrays are
      • //implemented alike? let's see
      • echo &quot;$myphonebook[0]&quot;; // sbabu
      • echo &quot;$myphonebook[1]&quot;; // 5348
      • Some functions useful in this context are sort(), next(), prev(), each().
    • Environment Variables
      • If the page &quot;http://domain.com/company/test.php” contains the code <?php echo &quot;[$REQUEST_URI]&quot;; ?> it prints out [/company/test.php]
    • Custom Functions
      • You can define your own functions as shown below. Return values can be any of the data types.
      • function foo ($arg_1, $arg_2, ..., $arg_n) {
      • echo &quot;Example function. &quot;;
      • return $retval;
      • }
      • Any valid PHP code may appear inside a function, even other functions and class definitions. Functions must be defined before they are referenced.
    • Custom Functions - Example
      • <?
      • function AddFive ($TheNumber)
      • {
      • $TheNumberPlusFive = $TheNumber + 5;
      • print(&quot;$TheNumber plus 5 equals $TheNumberPlusFive.<br>&quot;);
      • }
      • AddFive(15);
      • AddFive(23);
      • ?>
    • Objects
      • To create an object, use the new statement.
      • class foo {
      • function do_foo () {
      • echo &quot;Doing foo.&quot;;
      • }
      • }
      • $bar = new foo;
      • $bar->do_foo();
    • Classes
      • class Employee {
      • var $empno; // employee number
      • var $empnm; // name
      • function add_employee($in_num, $in_name){
      • $this->empno = $in_num;
      • $this->empnm = $in_name;
      • }
      • function show() {
      • echo &quot;$this->empno, $this->empnm&quot;;
      • return;
      • }
      • function changenm($in_name){
      • $this->empnm = $in_name;
      • }
      • }
      • $sbabu = new Employee;
      • $sbabu->add_employee(10,&quot;sbabu&quot;);
      • $sbabu->changenm(&quot;babu&quot;);
      • $sbabu->show();
    • Guest Book Example
      • guest.htm
        • A form where the site visitor will type his name and message.
        • Submit button will call the guestbook.php file.
      • guestbook.php
        • open the guestbook.txt file
        • read old contents, add the new comment
        • display all comments to the browser
        • also add the new comment to the guestbook.txt file
      • guestbook.txt
        • Starts with welcome message.
        • Keeps adding the comments added by users.
        • Don't forget to change the file permission from read to write once uploaded to the server.
    • guest.htm
      • <body>
      • <form name=&quot;form1&quot; method=&quot;post&quot; action=&quot;guestbook.php&quot;>
      • <input type=&quot;text&quot; name=&quot;visitor&quot;><p>
      • <textarea name=&quot;comment&quot; rows=&quot;10&quot; cols=&quot;40&quot;></textarea><p>
      • <input type=&quot;submit&quot; name=&quot;Submit&quot; value=&quot;Submit&quot;>
      • </form>
      • </body>
    • guestbook.php
      • <?
      • $file=&quot;guestbook.txt&quot;;
      • $handle=fopen($file, &quot;r+&quot;);
      • $prevtext=fread($handle,filesize(&quot;$file&quot;));
      • $new=&quot;<div align=&quot;center&quot;> Posted by: <u><b>$visitor</b></u> <br> <p><font face=&quot;Fixedsys&quot;> $comment </font></p> <hr> </div>&quot;;
      • $total = $prevtext . $new;
      • fclose($handle);
      • echo &quot;$total&quot;;
      • $handle=fopen($file, &quot;w&quot;);
      • fwrite($handle, $total);
      • fclose($handle);
      • ?>
    • guestbook.txt
      • <p>Welcome</p>
    • Cookies
      • To create and modify a cookie, use the PHP function setcookie(). setcookie() takes up to six arguments, depending upon how much control you want over the cookie and who can read its value.
      • The simplest way of setting a cookie is like this: setcookie('name', 'bret');
    • Add the following to the top of guestbook.php
      • <?php
      • if (!$mevisit1){
      • @setcookie(&quot;mevisit1&quot;, &quot;$visitor&quot;, time()+3600);
      • }
      • If ($mevisit1 != $visitor){
      • echo &quot;hi $mevisit1!, we know you are not $visitor!!&quot;;
      • }
      • else {
      • echo &quot;welcome back, $visitor&quot;;
      • }
    • Variables through URL
      • <html>
      • <font color=<?php echo $mycolor; ?>>THis color is decided in the variable</font>
      • </html>
      • test.php?mycolor=blue
    • Control Structure (If - Else)
      • You can use the control structures if and elseif: if ($user_count > 200) { print &quot;The site is busy right now!&quot;; } elseif ($user_count > 100) { print &quot;The site is sort of active right now!&quot;; } else { print &quot;The site is lonely - only $user_count user logged on.&quot;; }
    • Control Structure (while or for)
      • To Print the following you can use looping structures such as for and while : I have eaten 4 bagels today. I have eaten 5 bagels today. I have eaten 6 bagels today. I have eaten 7 bagels today.
      • $i = 4; while ($i < 8) { print &quot;I have eaten $i bagels today. &quot;; $i++; }
      • for ($i = 4; $i < 8; $i++) { print &quot;I have eaten $i bagels today. &quot;; }
    • Control Structure (foreach)
      • <?php
      • $month = array(&quot;January&quot;, &quot;February&quot;, &quot;March&quot;, &quot;April&quot;, &quot;May&quot;, &quot;June&quot;, &quot;July&quot;, &quot;August&quot;, &quot;September&quot;, &quot;October&quot;, &quot;Novemeber&quot;, &quot;December&quot;);
      • echo &quot;<FORM METHOD=POST ACTION = results.php>&quot;;
      • echo &quot;<SELECT NAME=column_name >&quot;;
      • echo&quot;<OPTION VALUE=&quot;/&quot;>Pick a Month</OPTION>&quot;;
      • foreach($month as $MON)
      • {
      • echo &quot;<OPTION VALUE=&quot;$MON&quot;>$MON</OPTION>&quot;;
      • }
      • echo &quot;</SELECT></FORM>&quot;;
      • ?>
    • Switch
      • Switch is an elegant replacement for multiple if-elseif-else structure.
      • switch ($i) {
      • case 0:
      • print &quot;i equals 0&quot;;
      • case 1:
      • print &quot;i equals 1&quot;;
      • case 2:
      • print &quot;i equals 2&quot;;
      • }
      • break, continue
      • break breaks out of current looping control-scructures.
      • continue is used within looping structures to skip the rest of the current loop iteration and continue execution at the beginning of the next iteration.
    • Mobile Handset Dealer’s website Example
      • index.php The file with a drop down option.
      • myfiles/photos.htm A html file with photos section.
      • myfiles/products.htm A html file with products section.
      • myfiles/printer.php This .php file will display the contents of the current page with the help of printer.css stylesheet.
      • myfiles/normal.css Normal stylesheet file.
      • myfiles/printer.css Printer friendly stylesheet file.
      • myfiles/A6188.gif
    • Index.php
      • <HTML>
      • <HEAD>
      • <LINK rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;include/normal.css&quot;>
      • </HEAD>
      • <BODY>
      • <FORM name=&quot;infosys&quot;>
      • <SELECT size=&quot;1&quot;
      • onchange=&quot;window.location=document.infosys.navigation.options[document.infosys.navigation.selectedIndex].value&quot; name=&quot;navigation&quot;>
      • <OPTION selected>-------------------</OPTION>
      • <OPTION value=&quot;index.php?do=photos&quot;>photos </OPTION>
      • <OPTION value=&quot;index.php?do=products&quot;>products</OPTION>
      • </SELECT>
      • <?php
      • switch ($do) {
      • case &quot;photos&quot;:
      • include “myfiles/photos.htm&quot;;
      • $printer=“myfiles/printer.php?print_mode=1&&doc=photos.htm&quot;;
      • break;
      • case &quot;products&quot;:
      • include “myfiles/products.php&quot;;
      • $printer=“myfiles/printer.php?print_mode=1&&doc=products.htm&quot;;
      • break;
      • } ?>
      • </FORM>
      • <P>Want to print? <a href=&quot;<?php echo &quot;$printer&quot; ?>&quot;>Printer Friendly Page</a> </P>
      • </BODY>
      • </HTML>
    • myfiles/photos.htm
      • <html>
      • <head>
      • <title>Photo Gallery</title>
      • </head>
      • <body>
      • <P> Please visit our photo gallery
      • <a href=“http://yahoo.com/photos&quot;>Here</a>
      • </body>
      • </html>
    • Myfiles/products.htm
      • <html>
      • <head>
      • <title>Product specification</title>
      • </head>
      • <body>
      • <p>Motorola A6188 </P> Welcome to your new office. The new Motorola Accompli A6188 is a Chinese/English WAP-enabled PDA and mobile phone. Which makes it the world's smartest way to..<P>
      • <img src=include/a6188.gif>
      • <TABLE>
      • <TR> <TD>Device Name </TD> <TD>Accompli A6188 </TD> </TR>
      • <TR> <TD>GSM 900 </TD> <TD> Yes</TD> </TR>
      • <TR> <TD>Input Method </TD> <TD>On-screen keyboard/Voice Recognition </TD> </TR>
      • </TABLE>
      • </body>
      • </html>
    • myfiles/printer.php
      • <html>
      • <head>
      • <STYLE TYPE=&quot;text/css&quot;>
      • <?PHP
      • if ($print_mode != 1) {
      • include 'normal.css';
      • } else {
      • include 'printer.css';
      • }
      • ?>
      • </STYLE>
      • </head>
      • <body>
      • Print Friendly Page:
      • <?PHP
      • include &quot;$doc&quot;;
      • ?>
      • </body>
      • </html>
    • myfiles/normal.css myfiles/printer.css
      • normal.css
      • body { color: white; background-color: #003366; font-size: 12pt}
      • A{color:#6666FF; text-decoration:none}
      • A:visited{color:#6666FF; text-decoration:none}
      • A:active{color:#6666FF; text-decoration:none}
      • A:hover{color:#6666FF; text-decoration:underline}
      • printer.css
      • BODY {margin: 2em; color: black; font-size: 12pt; text-indent: 2em;
      • /* i.e. 36pt */}
      • IMG {display: none}
      • table {font-size: 12pt; background: none; width: 100%;}
    • myfiles/a6188.gif
    • Estate broker example
      • broker.htm A simple form with 4 fields Name, Surname, FlatHave and FlatWant with a submit button that will call the process_form.php file.
      • process_form.php The variables $Name, $Surname, $FlatHave and $FlatWant are added to the “list” table of “broker” database. A mail is sent to the manager about the new entry added.
      • display.php Display everything from “list” table.
    • broker.htm
      • <html>
      • <head>
      • <title> Add Record</title>
      • </head>
      • <body>
      • Please add the record here...
      • <FORM name=&quot;myform&quot; ACTION=&quot;process_form.php&quot; METHOD=&quot;POST&quot;>
      • Your Name: <INPUT TYPE=&quot;TEXT&quot; NAME=&quot;Name&quot;><br>
      • Your Surname: <INPUT TYPE=&quot;TEXT&quot; NAME=&quot;Surname&quot;><br>
      • Flat Have at: <INPUT TYPE=&quot;TEXT&quot; NAME=&quot;FlatHave&quot;><br>
      • Flat Want at: <INPUT TYPE=&quot;TEXT&quot; NAME=&quot;FlatWant&quot;><br>
      • <INPUT TYPE=&quot;SUBMIT&quot; VALUE=&quot;Add Record&quot; NAME=&quot;sendit&quot;>
      • <INPUT TYPE=&quot;SUBMIT&quot; VALUE=&quot;Cancel&quot; NAME=&quot;cancelit&quot;><br>
      • </FORM>
      • </body>
      • </html>
    • process_form.php
      • <html>
      • <body>
      • <?php
      • mysql_connect(&quot;&quot;,&quot;&quot;,&quot;&quot;);
      • mysql_select_db(&quot;broker&quot;);
      • mysql_query (&quot;INSERT INTO list values (´´, ´$Name´, ´$Surname´, ´$FlatHave´, ´$FlatWant´);&quot;);
      • ?>
      • Thank you for your entry.
      • </body>
      • </html>
    • Mail
      • Now can you send an e-mail to the manager whenever someone adds an entry?
      • Add the following code in the process_form.php file
      • <?php
      • mail(&quot;shantanuo@hotmail.com&quot;, &quot;Entry Added&quot;,&quot;
      • Name : $Name
      • Surname : $Surname
      • Flat Have : $FlatHave
      • Flat Want : $FlatWant
      • &quot;);
      • ?>
    • display.php
      • <html>
      • <body>
      • The data stored into the “broker” Database -“List” Table.
      • <?php
      • mysql_connect(&quot;&quot;,&quot;&quot;,&quot;&quot;);
      • mysql_select_db(&quot;broker&quot;);
      • $query = &quot;select * from list&quot;;
      • $result = mysql_query ($query);
      • while($row = mysql_fetch_array($result))
      • {
      • echo $row[Name] .&quot;<br>&quot;. $row[Surname].&quot;</p>&quot;;
      • }
      • ?>
      • </body>
      • </html>
    • contents of database student Part I
      • <?php
      • $dbname = &quot;student&quot;;
      • $loginname = &quot;shaileshr21&quot;;
      • $loginpass = &quot;&quot;;
      • $dbhost = &quot;mysql&quot;;
      • echo('<html><body bgcolor=&quot;#FFFFFF&quot;>');
      • echo('<font face=&quot;arial&quot; size=&quot;+4&quot;><center>');
      • echo(&quot; $dbname&quot;);
      • $id_link = @mysql_connect($dbhost, $loginname, $loginpass);
      • $tables = mysql_list_tables($dbname, $id_link);
      • $num_tables = mysql_num_rows($tables);
      • // store table names in an array
      • $arr_tablenames[] = '';
    • contents of database student Part II
      • // store number of fields per table(index 0,1,2..) in an array
      • $arr_num_fields[] = '';
      • for ($i=0; $i < $num_tables; $i++) {
      • $arr_tablenames[$i] = mysql_tablename($tables, $i);
      • $arr_num_fields[$i] = mysql_num_fields(mysql_db_query($dbname, &quot;select * from $arr_tablenames[$i]&quot;, $id_link));
      • }
      • // store field names in a multidimensional array:
      • // [i] == table number, [ii] == field number for that table
      • for ($i=0; $i < $num_tables; $i++) {
      • for ($ii=0; $ii < $arr_num_fields[$i]; $ii++) {
      • $result = mysql_db_query($dbname, &quot;select * from $arr_tablenames[$i]&quot;, $id_link);
      • $hash_field_names[$i][$ii] = mysql_field_name($result, $ii);
      • }
      • }
    • contents of database student Part III
      • for ($i=0; $i < $num_tables; $i++) {
      • echo(&quot;<center><h2> $arr_tablenames[$i] </h2></center>&quot;);
      • echo('<table align=&quot;center&quot; border=&quot;1&quot;><tr>');
      • $result = mysql_db_query($dbname, &quot;select * from $arr_tablenames[$i]&quot;, $id_link);
      • for ($ii=0; $ii < $arr_num_fields[$i]; $ii++) {
      • echo(&quot;<th>&quot;);
      • echo $hash_field_names[$i][$ii];
      • echo(&quot;</th>&quot;);
      • }
      • echo(&quot;</tr><tr>&quot;);
      • $number_of_rows = @mysql_num_rows($result);
      • for ($iii = 0; $iii < $number_of_rows; $iii++) {
      • $record = @mysql_fetch_row($result);
      • for ($ii=0; $ii < $arr_num_fields[$i]; $ii++) {
      • echo(&quot;<td>&quot;);
      • // echo $record[$ii];
      • $mytext = nl2br($record[$ii]);
      • echo $mytext;
      • echo(&quot;</td>&quot;);
      • }
      • echo(&quot;</tr>&quot;);
      • }
      • echo(&quot;</table>&quot;);
      • }
      • echo('</body></html>');
      • ?>
    • Display Bookmarks Part I
      • <html>
      • <head>
      • <basefont face=&quot;Arial&quot;>
      • </head>
      • <body>
      • <?php
      • // set database server access variables:
      • $host = &quot;mysql&quot;;
      • $user = &quot;shaileshr21&quot;;
      • $pass = &quot;&quot;;
      • $db = &quot;student&quot;;
      • // open connection
      • $connection = mysql_connect($host, $user, $pass) or die (&quot;Unable to connect!&quot;);
      • // select database
      • mysql_select_db($db) or die (&quot;Unable to select database!&quot;);
      • // create query
      • $query = &quot;select concat('<a href=&quot;',Website,'&quot;>', Website, '</a>'), Explanation from Bookmarks where Catgegory='$mycat'&quot;;
    • Display Bookmarks Part II
      • echo &quot;<h2>$mycat</h2>&quot;;
      • // execute query
      • $result = mysql_query($query) or die (&quot;Error in query: $query. &quot;.mysql_error());
      • // see if any rows were returned
      • if (mysql_num_rows($result) > 0) {
      • // yes
      • // print them one after another
      • echo &quot;<table cellpadding=10 border=1>&quot;;
      • while($row = mysql_fetch_row($result)) {
      • echo &quot;<tr>&quot;;
      • echo &quot;<td>&quot;.$row[0].&quot;</td>&quot;;
      • echo &quot;<td>&quot; . $row[1].&quot;</td>&quot;;
      • echo &quot;</tr>&quot;;
      • }
      • echo &quot;</table>&quot;;
      • }
      • else {
      • // print status message
      • echo &quot;No rows found!&quot;;
      • }
      • // free result set memory
      • mysql_free_result($result);
      • mysql_close($connection);
      • ?>
      • </body>
      • </html>
    • Mysql front-ends
      • phpMyAdmin Search across tables, Most Popular, (free software)
      • phpFlashMyAdmin User friendly flash interface, graphical representation of innodb tables, (Paid)
      • MySql Data Manager Better Administrative interface in perl (Paid)
    • Mysql interface
      • CSV to MySQL http://www.sqldbu.com/eng/sections/tips/normalize.html Upload the .csv and get the create table and insert statements
      • MySQL to CSV http://saraswaticlasses.com/sites/dump.php Type the table name and password to download the records in the excel form.
      • MySQL to RSS http://saraswaticlasses.com/sites/createrss.htm Publish the records from your mysql database using the RSS feed without any web interface.
    • Simple RSS Reader
      • <?php
      • $cookies = array();
      • getcookies();
      • if ($_GET[&quot;deleteall&quot;]==&quot;yes&quot;) {
      • foreach($cookies as $id=>$url) {
      • deletecookie($id);
      • }
      • header(&quot;Location: $PHP_SELF&quot;);
      • } elseif(is_numeric($_GET[&quot;delete&quot;])) {
      • deletecookie($id);
      • header(&quot;Location: $PHP_SELF&quot;);
      • } elseif(!empty($_GET[&quot;formfeedurl&quot;])) {
      • addcookie($formfeedurl);
      • header(&quot;Location: $PHP_SELF&quot;);
      • } elseif ($cookiecount > 0) {
      • foreach($cookies as $id=>$url) {
      • echo &quot;<!-- FeedCookie[$id] == $url -->&quot;; // For debugging, or something.
      • ?>
      • <script language=&quot;javascript&quot; src=&quot;http://p3k.org/rss/index.r?url=<?php echo $url; ?>%3Ff%3D7&amp;align=left&amp;width=300&amp;frameColor=black&amp;titleBarColor=%23add8e6&amp;titleBarTextColor=black&amp;boxFillColor=white&amp;textColor=black&amp;fontFace=&amp;maxItems=7&amp;compact=&amp;showXmlButton=&amp;javascript=true&quot;&quot;></script>
      • <?php
      • }
      • } else {
      • // There are no feeds defined.
      • }
      • ?>
    • Simple RSS Reader II
      • <p style=&quot;clear: both&quot;>
      • <form action=&quot;<?php echo $PHP_SELF; ?>&quot;>
      • <input type=&quot;text&quot; name=&quot;formfeedurl&quot; size=&quot;26&quot;>
      • <input type=&quot;submit&quot; name=&quot;Add&quot; value=&quot;Add Feed&quot;>
      • </form>
      • <a href=&quot;<?php echo $PHP_SELF; ?>?deleteall=yes&quot;>Delete All Cookies</a><p>
      • <a href=&quot;<?php echo $PHP_SELF; ?>?source=yes&quot;>Source Code</a><p>
    • Simple RSS Reader Part III
      • <?php
      • function getcookies() {
      • global $cookiecount, $cookies;
      • foreach ($_COOKIE as $name=>$value) {
      • if (ereg(&quot;^FeedCookie-([0-9]{1,2})$&quot;,$name,$regs)) {
      • $id = (int)$regs[1];
      • $cookies[$id] = $value;
      • }
      • }
      • $cookiecount = count($cookies);
      • }
      • function addcookie($value) {
      • global $cookies;
      • for ($i=0; $i<100; $i++) {
      • if (!isset($cookies[$i])) {
      • $id = $i;
      • break;
      • }
      • }
      • if (!isset($id)) {
      • echo &quot;No ID.&quot;;
      • return 0;
      • }
      • setcookie(&quot;FeedCookie-$id&quot;,$value,time()+31536000);
      • return 1;
      • }
      • function deletecookie($id) {
      • global $cookies;
      • if (isset($cookies[$id])) {
      • setcookie(&quot;FeedCookie-$id&quot;,&quot;&quot;,time()-3600);
      • return 1;
      • } else {
      • return 0;
      • }
      • }
      • if ($source==yes) {
      • $source = 'simplefeed.php';
      • highlight_file( $source );
      • }
      • ?>