|What is a PHP?
PHP or Personal Home Page is a general-purpose scripting language originally designed for web development to produce dynamic web pages. For this purpose, PHP code is embedded into the HTML source document and interpreted by a web server with a PHP processor module, which generates the web page document. It also has evolved to include a command-line interface capability and can be used in standalone graphical applications. PHP can be deployed on most web servers and as a standalone interpreter, on almost every operating system and platform free of charge. A competitor to Microsoft’s Active Server Pages (ASP) server-side script engine and similar languages, PHP is installed on more than 20 million websites and 1 million web servers.
PHP was originally created by Rasmus Lerdorf in 1995. The main implementation of PHP is now produced by The PHP Group and serves as the de facto standard for PHP as there is no formal specification. PHP is free software released under the PHP License which is incompatible with the GNU General Public License (GPL) due to restrictions on the usage of the term PHP.
What is PHP Used For?
PHP can collect user information – By this I mean, you can let your user directly interact with the script. This can be something really simple, like collecting the temperature from the user that they want to convert from degrees to another format, or it can be more extensive information, like adding their information to an address book, or letting them post on a forum.
PHP can interact with MySQL databases – And in doing this, the possibilities are endless. You can write users information to the database and you can retrieve information from the database. This allows you to create pages on the fly using the contents of the database. You can even do more complex things like setting up a login system, creating a website search feature, or keep your store’s product catalogue and inventory online.
PHP and GD Library can create graphics – You can use PHP to create simple graphics on the fly. You can also use it to edit existing graphics. You might want to do this to resize images, rotate them, or grayscale them. Some practical applications for this are allowing users to edit their avatars or creating CAPTCHA verifications. You can also create dynamic graphics that are always changing, my favorite example being dynamic twitter signatures.
PHP is a widely-used general-purpose scripting language that is especially suited for Web development and can be embedded into HTML.
In an HTML document, PHP script (similar syntax to that of Perl or C ) is enclosed within special PHP tags. Because PHP is embedded within tags, the author can jump between HTML and PHP (similar to ASP and Cold Fusion) instead of having to rely on heavy amounts of code to output HTML. And, because PHP is executed on the server, the client cannot view the PHP code.
PHP can perform any task that any CGI program can do, but its strength lies in its compatibility with many types of databases. Also, PHP can talk across networks using IMAP, SNMP, NNTP, POP3, or HTTP.
PHP is compatible to almost all the packages by Manashosting.
For some of the php compatible package click here
Manashosting has the innovative web hosting technology to implement in the web hosting domestic market. The web hosting panel provided by Manashosting as control panel of your domain is one among the best in the current market. It is your domain control panel, from where you manage all aspects of your domain and its contents. The domain control panel provided by web hosting company has been designed with the intention of making it easier for an individual to even act as a domain registrar possessing an authority to register a domain for self or for its clients and every now and then on the basis of requirement he can modify the web hosting account with every new update hence the domain resellers can benefit from such technology with the authority to register domain for its clients. It has become more user-friendly and more reliable.
When you access your web hosting account, everything you need is available right there in hosting panel or domain control panel itself.
The main tools available within your panels let you do the basic domain and web space administration required to keep your website in order. You can set or reset your login details, ftp details and email accounts from web hosting control panel. You can access and maintain all your databases from your web hosting control panel as well, review basic statistics of your website, check your bandwidth use, check which scripts are supported, block certain IP addresses (depends on the web hosting package terms) from accessing your website, check for and clear up viruses, make a backup of your entire site, and other general maintenance actions, or grooming, of your domain.
If your web hosting plan allows it, you can actually set up different domains within your single account and control them all through your hosting or domain control panel.
Within your web hosting panel, you will more often than not find a handy little extra applications called file manager. It is what made easier for a client to deploy website files in web space without taking the help of ftp account. Inbuilt feature of web hosting panel helps doing so, and this brilliant tool really comes as a handy element for hosting resellers who in this case every now and then need not have to memorize or search for ftp login information for different domains of its clients. It is not restricted to limited upload or download. One can deploy unlimited files in its web space using the feature however restricted to limited upload in some online software at one time due to unavailability to browse for unlimited files. Bandwidth doesn’t get much affected with such move and unlimited upload and download can easily be taken into process (incase the package has unlimited web space and bandwidth facility).
Some hosting panel has the feature of adding java applications separately to its web space package. As java is an important and widely used application most of the web hosting companies will make it sure the compatible features to enable the java application resides in the online software or control panel.
Many web hosting companies have added online shopping application in its web space packages which helps clients to add up the application to its website at ease rather swaying the process of manipulation and editing. These come free nowadays with web hosting packages. Most of the web hosting companies have included such applications for free in its web hosting package to let their client get benefited for hosting web applications.
Manashosting has started providing free search engine submission for its 2 years old clients. Based on the demand of our clients which they are looking to get for free along with their web hosting i.e. web space packages Manashosting has stated implementing this technique to help our clients to submit their website URL for free in over 8 lakh search engines.
PHP is a popular scripting language that was originally designed to program dynamic Web pages. Its most popular use is for server-side scripting, but PHP is also used for command-line scripting and for writing desktop applications.
PHP is server-side:
PHP is HTML-embedded:
The PHP bits are parsed (“translated”) by the server – in the examples presented here, they will be mainly used to produce more HTML code. The HTML code on the page is sent directly to the browser.
Whitespace (tabs, spaces, returns) doesn’t really matter. You can write <?$title=”mytitle”;?> or <? $title = “mytitle” ; ?>, both work.
ariables can have just about any size. For example, all the text you are reading now is the value of one big variable named $content.
Variable names start with a dollar sign (“$”), followed by an alphabetic character or an underscore, optionally followed by alphanumeric characters or underscores.
print and echo do just about the same thing: they send their argument to the browser. There is a small difference between them, but I’m not yet sure what it is…;)
When using print, echo, or when assigning a string value to a variable, you have the choice between using double quotes or single quotes (if the argument is a naked variable, you can also use no quotes at all).
Single quotes will reproduce the text between them with no modifications. Line breaks, spacings, variable names and fun characters will all come out how you printed them. But! if the text between the quotes contains single quotes, you have to replace them by the escape sequence “backslash-quote”: “\'”. And what if you want a backslash? Use a double backslash: “\\”.
Double quotes will replace variables by their value, and ignore newlines and tabs. Here are some escape sequences: newline = “\n”, tab = “\t”, double quote = “\””, backslash = “\\”, dollar = “$”…
If you want to define a very long variable (for example, lots of text), you might want to use the here doc syntax.
An empty variable, e.g. $potato = ”; will return false when its boolean value is called for. It will not create an error if you attempt to print it.
As it should be clear from the example above, an include is a simple ASCII file, and there is no special “dressing” to put around it. Just cut out a chunk of HTML from a page and stick it in a separate file: you have an include.
Include files can have any extension. You can name an include “blahblah.bla” if you wish.
The require function replaces itself with the contents of the file it calls, whereas include is more like a branch that points to it. This can make a difference if you are using a loop to call different includes: if you use require, the statement will be replaced by the first file during the first loop, and you will end up with (e.g.) three times the same file instead of three different files. If you are not quite sure which to choose, follow this rule of thumb: In control statements and functions, use include. Otherwise, use require (which is supposed to be a little faster).
An include can call another include. They include is read just as a normal PHP file, which means that you can put in an include anything that you would put in a “normal” PHP file.
Calling an include with relative or server-relative urls sometimes creates trouble. I usually use include (“$DOCUMENT_ROOT/path/filename”); or include(“http://$HTTP_HOST/path/filename”) – do a few tests on your own server to see what works for you. You will get a listing of server variables like $DOCUMENT_ROOT or $REQUEST_URI with the function phpinfo().
Make a standard page for your site. Don’t forget to polish up your HTML and validate it.
Identify the “variable” parts of your page. The bits of HTML that change from page to page will be replaced by PHP variables, like in the “Title” example higher up in this page. This is how the finished design template would look like.
Create a new file, which could be named here “example.php3”, and give the necessary values to the needed variables to produce the finished page once the server has parsed the PHP. Here is what this “PHP page” could look like.
You can now create as many “PHP pages” as your site requires, which all call up the design template. This allows you to create new pages without worrying about design and layout, and it also allows you to change the design completely by modifying a single file.
By default, variables are always assigned by value. That is to say, when you assign an expression to a variable, the entire value of the original expression is copied into the destination variable. This means, for instance, that after assigning one variable’s value to another, changing one of those variables will have no effect on the other. For more information on this kind of assignment, see the chapter on Expressions.
PHP also offers another way to assign values to variables: assign by reference. This means that the new variable simply references (in other words, “becomes an alias for” or “points to”) the original variable. Changes to the new variable affect the original, and vice versa.
It is not necessary to initialize variables in PHP however it is a very good practice. Uninitialized variables have a default value of their type depending on the context in which they are used – Booleans default to FALSE, integers and floats default to zero, strings (e.g. used in echo ()) are set as an empty string and arrays become to an empty array.
Relying on the default value of an uninitialized variable is problematic in the case of including one file into another which uses the same variable name. It is also a major security risk with register global turned on. E_NOTICE level error is issued in case of working with uninitialized variables, however not in the case of appending elements to the uninitialized array. isset() language construct can be used to detect if a variable has been already initialized.
You may be wondering why you should choose PHP over other languages such as Perl or even why you should learn a scripting language at all. I will deal with learning scripting languages first. Learning a scripting language, or even understanding one, can open up huge new possibilities for your website. Although you can download pre-made scripts from sites like hot scripts, these will often contain advertising for the author or will not do exactly what you want. With an understanding of a scripting language you can easily edit these scripts to do what you want, or even create your own scripts.
Using scripts on your website allows you to add many new ‘interactive’ features like feedback forms, guestbooks, message boards, counters and even more advanced features like portal systems, content management, advertising managers etc. With these sorts of things on your website you will find that it gives a more professional image. As well as this, anyone wanting to work in the site development industry will find that it is much easier to get a job if they know a scripting language.
Writing PHP on your computer is actually very simple. You don’t need any special software, except for a text editor (like Notepad in Windows). Run this and you are ready to write your first PHP script.
One of the major uses of a server side scripting language is to provide a way of sending e-mail from the server and, in particular, to take form input and output it to an e-mail address.
Mail is extremely easy to send from PHP, unlike using scripting languages which require special setup (like CGI). There is actually just one command, mail () for sending mail. It is used as follows:
This is actually a very important character when sending e-mail. It is the new line character and tells PHP to take a new line in an e-mail. It is very important that this is put in after each header you add so that your e-mail will follow the international standards and will be delivered.
The \n code can also be used in the body section of the e-mail to put line breaks in but should not be used in the subject or the To field.
Being able to place HTML code into your PHP is very useful, but what happens if you want to put the value of a variable into the code. Unlike when using an echo or print statement, you can’t just put in the variable name as this section is not actually part of the PHP code. Instead you must just put in a little PHP.
To output text in your PHP script is actually very simple. As with most other things in PHP, you can do it in a variety of different ways. The main one you will be using, though, is print. Print will allow you to output text, variables or a combination of the two so that they display on the screen.
The print statement is used in the following way:
All hosts have the latest version of PHP and MySQL and all of them support .htaccess override. Some hosts even allow custom PHP.INI to further customize settings.
PHP is Web Scripting language originally created by Rasmus Lerdorf in 1995, as Personal Homepage Tools, now referred to as HyperText Preprocessor. After the PHP 3 release, the language gained popularity and today is one of the most used web programming languages for producing dynamic web sites. The newest version is 5 which adds many features, security, and enhanced OOP (Object Oriented Programming) support. PHP often comes in bundle with Apache httpd – web server and MySQL – relational database system; called LAMP or WAMP (L stands for Linux, W for windows). Many popular websites are powered by PHP including facebook.com, youtube (in the beginning), some google services, digg.com – the news portal and many others. WordPress the popular weblog (blog) platform is built with PHP.
PHP is one of the most popular server side scripting languages running today. It is used for creating dynamic webpages that interact with the user offering customized information. PHP offers many advantages; it is fast, stable, secure, easy to use, open source and fully supported by Servage Hosting.
PHP code is inserted directly into the HTML that makes up a website. When a visitor comes to the website, the code is executed. Because PHP is a server side technology, the user does not need any special browser or plug-ins to see the PHP in action. The beauty of PHP lies in its simplicity. It is easy to understand and learn.
Another key advantage of PHP is its connective abilities. PHP uses a modular system of extensions to interface with a variety of libraries such as graphics, XML, encryption, etc. In addition to extensions, PHP has many of server interfaces, database interfaces and other modules available.
Since PHP is an open source project, the PHP community is willing to share. If you are looking for a particular script, chances are another user has already created something similar. Check within the PHP community for availability. Likewise, if you have created a function that others might enjoy, be sure to post the code for others.
PHP and MySQL are usually associated with LAMP (Linux, Apache, MySQL, PHP). However, most PHP developer ( including me) is actually using Windows when developing the PHP application. So this page will only cover the WAMP (Windows, Apache, MySQL, PHP ). You will learn how to install Apache, PHP, and MySQL under Windows platform.
Installing apache is easy if you download the Microsoft Installer ( .msi ) package. Just double click on the icon to run the installation wizard. Click next until you see the Server Information window. You can enter local host for both the Network Domain and Server Name. As for the administrator’s email address you can enter anything you want.
Click the Next button and choose Typical installation. Click Next one more time and choose where you want to install Apache ( I installed it in the default location C:\Program Files\Apache Group ). Click the Next button and then the Install button to complete the installation process.
By default Apache’s document root is set to htdocs directory. The document root is where you must put all your PHP or HTML files so it will be process by Apache ( and can be seen through a web browser ). Of course you can change it to point to any directory you want. The configuration file for Apache is stored in C:\Program Files\Apache Group\Apache2\conf\httpd.conf (assuming you installed Apache in C:\Program Files\Apache Group). It’s just a plain text file so you can use Notepad to edit it.
For example, if you want to put all your PHP or HTML files in C:\www just find this line in the httpd.conf :
DocumentRoot “C:/Program Files/Apache Group/Apache2/htdocs”
and change it to :
First, extract the PHP package (php-4.3.10-Win32.zip ). Extract the package in the directory where Apache was installed (C:\Program Files\Apache Group\Apache2). Change the new created directory name to php (just to make it shorter). Then copy the file php.ini-dist in PHP directory to you windows directory (C:\Windows or C:\Winnt depends on where you installed Windows) and rename the file to php.ini. This is the PHP configuration file and we’ll take a look what’s in it later on.Next, move the php4ts.dll file from the newly created php directory into the sapi subdirectory. Quoting from php installation file you can also place php4ts.dll in other places such as :
In the directory where apache.exe is start from ( C:\Program Files\Apache Group\Apache2 \bin) In your %SYSTEMROOT%\System32, %SYSTEMROOT%\system and %SYSTEMROOT% directory.
Note: %SYSTEMROOT%\System32 only applies to Windows NT/2000/XP) In your whole %PATH%Apache doesn’t know that you just install PHP. We need to tell Apache about PHP and where to find it. Open the Apache configuration file in C:\Program Files\Apache Group\Apache2\conf\httpd.conf and add the following three lines :
Load Module php4_module php/sapi/php4apache2.dll AddType application/x-httpd-php .php Add type application/ x-httpd-php-source .phps The first line tells Apache where to load the dll required to execute PHP and the second line means that every file that ends with .php should be processed as a PHP file. You can actually change it to anything you want like .html or even .asp! The third line is added so that you can view your php file source code in the browser window. You will see what this mean when you browse this tutorial and click the link to the example’s source code like this one. Now restart Apache for the changes to take effect (Start > Programs > Apache HTTP Server 2.0.50 > Control Apache Server > Restart) . To check if everything is okay create a new file, name it as test.php and put it in document root directory ( C:\Program Files\Apache Group\Apache2\htdocs). The content of this file is shown below.<?php