Archive

Archive for the ‘PHP’ Category

PHP strip_tags : Remove HTML markup from a string

December 10th, 2009 Shyju No comments

strip_tags is a PHP function which will remove all HTML mark up from a string.This will remove PHP tags and XML mark from the input string if there is any

Ex : $strPreviewName=’I am <b>Bold</b>and<i>Italic</i>’;

The output of echo $strPreviewName would show

I am Bold and Italic.

Now this would make problems in cases where u need to take a substring of the first string or trim the string to  take the first 50 characters .Then it would break the HTML markup and which will leads to the rest of the page contents to be affected by the styles mentioned in the first string. In this case,we can use strip_tags function to remove all HTML markups from the string.

Ex : $strPreviewName=’I am <b>Bold</b>and<i>Italic again</i>’;

$strPreviewNameUpdated =strip_tags($strPreviewName);

The output of echo $strPreviewNameUpdatedwould show

I am Bold and Italic.

Categories: PHP Tags:

How to use WAMP (Windows-Apache-MySQL-PHP) to setup your PHP development

July 2nd, 2008 Shyju No comments


Last time, i wrote something about Configuring PHP and Apache.But in reality me too did not liked it to do this tedious task.Fortunately one of my friend who was working with PHP for some years told me about WAMP.This guy helped me to get a latest version of WAMP and we installed it ,started working on it. really cool !

WAMP stands for Windows-Apache-MySQL-PHP.I would like to describe WAMP as an Ideal execution environment for developing PHP-MySQl Applications with Apache websercer in Windows platform.

In wamp ,we need not bother about editing the configuration files ,which may be a boring task for some of us,Instead we can do all these(up to an extend) on the installation wizard .Still wamp allow the user to have access to all the config files in one click.You need not go for a search with file name ini.php / httpd.config

You can download WAMP server from here

Once you install wamp,start the wamp server from the start menu.you can see a systray icon in the right bottom side of screen adjacent to the time

WAMP Server SysTrayMenu

Left click on WampServer’s SysTray icon will help us to do the followings:

  • Control Apache and MySQL services
  • Switch online/offline staus
  • install and switch Apache, MySQL and PHP releases
  • Access to MySQL DB front ends like PhpMyAdmin/Sqlite Manager
  • View logs
  • View/Edit configuration settings files..

Now Let us start…………………

When we install our WAMP server in our PC, the installation program automatically create a folder named www inside wamp folder.You can Put your projects in this folder.Take a browser and inthe addressbar type,

http://localhost

WAMP Homepage

Your browser will render a page like the above.There you can find a Heading called “Your Project”.There it will display all the projects we have put under www directory

Wamp ProjectList

This is a snapshot from my PC.30JUNe,Liveprojects,MyBB,MyForum,MyWordpress ,NewFolder are Projects created by me.You can click any one of this iems to navigate to that project.

Above the You projects Title,You can see the Caption “Tools”,under that you can see a list having items “phpinfo”,”phpmyAdmin”,”sqllitemanager”,clicking on the phpinfo leads you to a web page which display all details regarding this installation packages.ie; for example,you can findout which all libraries are supporting our current php version and all.The remaining two,phpmyadmin,sqlitemager are two tools written in php to handle your mysql db.

Thats all Guys…. Try this and revert me if you have any queries .I shall come up with some more stuff soon


Categories: PHP Tags: , , ,

Starting with PHP-Apache

May 13th, 2008 Shyju 2 comments

I am not a novice PHP programmer.rather i am also a beginner.here i am presenting some stuffs which i tried and worked.i would like to thank my friend ANILKUMAR who helped me to learn these stuffs

i think it is better to start from the basics.So shall we start from the platform ? Yes ! we should.

for running a serverside program,we need a WebServer.we all may know the typical webserver,IIS (Intrenet Information Server) incorporated with windows operating systems.but right now i am skipping it as all of us know little bit of IIS configuration and related stuffs . No ? (anyway we shall disucss it later )

i am going to talk about Apache server,a powerful product from the Apache foundation.

You can download apache server verisions from there. i have Apache 2.2.6 Server version.Run the Setup.It is quite eazy to run the wizard.the only place i suspect u may get stucked is the pane where u have to enter the Network domain,servername,Administrators email address .You can give localhost/ur local IP in the first two fields and give admin@localhost in the third field(Assume we are going to work on the same machine(same server)).

Once u finish the Installation wizard,u can verify by going to Start Menu- >Programs->Apache HTTP Server 2.2.6

Now We will Install PHP Engine.You can go to www.php.net and get the appropriate verision.i am tried with PHP 5 .Once ou download it,No need to Install anything.more over,you cant find a typical install /SetUp.exe there in the folder.no need to worry. just copy the folder which contains the unziped files and paste it in any one of your disk drives(C/D/E/F). thats All !.

Now that we’ve got PHP and Apache working separately, we need to get get them to work together.
from the Start menu option u can open the Configuration file (Start->Programs->Apache HTTP Server 2.2.6->Configure Apache server->Edit the apache httpd.config Configuration file) You can open it by any Editors like text pad/Notepad.

Now u can see the contents of the file .for a beginner ,it may be really difficult to understand what all these things .No need to bother about the contents.These are some configuration parameters which our apache server use for the execution.just go through the page.the page itself provides some general tutorials.You can find out a couple of lines starting with #LoadModule or LoadModule.just go to the end of those block of code.the # prefixed lines are commented lines

just add the following line @ the bottom of that blockof code
LoadModule php5_module “E:/php/php5apache2_2.dll”
You have to Change the Physical location to your folder

where u have the Extracted files.for me IT is the PHP Folder

in E drive.change the part before php5apache2_2.dll in the

path.(on the other habd u can make sure that this DLL exists

in that directory).

below that line add this line
AddType application/x-httpd-php .php
(This is to specify the Type of files)

Then below that line add this line
PHPIniDir “E:/php”
(Configuring the path to php.ini).You have to specify the

folder where u have those extracted php files and dlls.for

me it is E drive,PHP folder

thats all ! You have done it .Now You can save the file and

close it.Now we have to restrat the server to make these

chenges available.Go to the start menu->PRograms->Apachec

HTTP Server 2.2.6->Control Apache server->Restart

Thats all ……

write a small php program (copy this)

<html>
<body>
<form>
<?php
echo “I created my first PHP Program !”;

?>
</form>
</body>
</html>

save this as testprogram.php and put it in this folder
F:\Program Files\Apache Software Foundation\Apache2.2\htdocs

(for me It is F drive ,since i installed Apache on F Drive.for u it may be different)

then take a browser type

http://localhost/testprogram.php

press enter key.You can see your first php programs out put !

just try buddies .I will come up with some more stuff soon,(once i found those code’s are working)

Make Sure to Stop IIS in control panel->Administrative tools->services as you are running another web server(Apache)