Useful PHP Functions.

A quick reference of the most useful PHP functions to help you get started.

date.

This function returns the date in a format you specify using letters. For example, date(“D j M Y”) outputs dates in this format: Mon 7 Jan 2010.

echo.

Writes text to the document. You can use explode. Divides up some text into an array by looking for ‘separator’ letters or characters. Can be good if you’re using odd characters like | to separate data somewhere in your program.

fopen.

Opens a file on your web server, but can also be used to open a URL and so connect to another server.

fread.

Reads the contents of the file, either all at once or line by line.

header.

Allows you to set your own HTTP headers – most often used to control which MIME types things are sent with (the content-type header), or to tell the browser whether to cache or not (the cache-control header).

md5.

Takes some text and produces a ‘hash’ using the MD5 algorithm. This is often used to allow checking of users’ passwords without needing to save their passwords in a database in plain text. The sha1 function does the same thing, and is more secure but slower.

mysql_connect.

Connects to a MySQL server. You have to tell it where the server is (usually localhost), as well as your username and password.

mysql_select_db.

Chooses which MySQL database to open on the MySQL server you’re connected to.

mysql_query.

Sends any SQL commands you want to your MySQL server.

mysql_fetch_assoc.

Turns the results of a query sent to a MySQL server into an array, to make it easier to use in your program.

str_replace.

Replaces one word with another in some text. This is useful when it comes to inserting the HTML tags between paragraphs, for example.

strtotime.

Turns an English-language description of a date and time into a number representing that date and time (technically known as a Unix timestamp). This makes them easier to use with a database, as you can sort from the ‘highest’ (most recent) to the ‘lowest’ (longest ago) more easily. You can convert back from timestamps again by using the date function.

If you have trouble remembering the names of the PHP functions, go here http://www.ilovejackdaniels.com/php/php-cheat-sheet

Popularity: 6% [?]

If you enjoyed this post, make sure you subscribe to my RSS feed!

No tag for this post.

Home For Proofits runs on the Genesis Framework

Genesis Framework

Genesis empowers you to quickly and easily build incredible websites with WordPress. Whether you're a novice or advanced developer, Genesis provides the secure and search-engine-optimized foundation that takes WordPress to places you never thought it could go. It's that simple - start using Genesis now!

Take advantage of the 6 default layout options, comprehensive SEO settings, rock-solid security, flexible theme options, cool custom widgets, custom design hooks, and a huge selection of child themes ("skins") that make your site look the way you want it to. With automatic theme updates and world-class support included, Genesis is the smart choice for your WordPress website or blog.

Speak Your Mind

*

CommentLuv badge
Rss Feed Tweeter button Technorati button Reddit button Webonews button Delicious button Flickr button Stumbleupon button