This will be something that will knock your socks off!
Aptana has what is called Intellisense, this is nothing new. Many modern IDE’s have Intellisense for standard HTML, XML, CSS, JavaScript, and other languages like PHP, and Ruby.
This will be a place where you can store your various frameworks. I store the frameworks in there own folders separate from the production scripts for Three reasons. One, I can keep versions of my library’s. And Two so they are independent of the production application. And Three I can update all the Frameworks with SVN.
I am using Aptana Studio, build: 1.5.0.025215 at the time of writing this tutorial but from the previous versions I have used the steps remain the same.
Open Aptana Studio (or Eclipse with your Aptana plug-in)
Open Aptana/Eclipse Preferences
Read on..
This is basically the exact same code I used in my Addressbook to export all of the contact information. Its good to note that a CSV is not a full backup, while you can restore the information in a Database you will not restore the structure.
A CSV file is commonly used to export information for manipulation, or importing into other applications.
You could export all of your contacts fro example and import them into Google contacts.
A file format is a particular way to encode information for storage in a computer file. Particularly, files encoded using the CSV format are used to store tabular data. The format dates back to the early days of business computing and is widely used to pass data between computers with different internal word sizes, data formatting needs, and so forth. For this reason, CSV files are common on all computer platforms.
From Wikipedia: http://en.wikipedia.org/wiki/Comma-separated_values
CSV files don’t have to have there values separated with a comma (,) you can use any character you like IE: | : or #
What do we want to do? Well we want to export all the data in a given table. Im this case its contact information, so each row will contain a series of columns containing personal information. When we execute the script we should Prompt for a download to the users computer, and we will also save a copy of the file to a folder on the server.
I’m not going to show how you connect to the Database as this should already be done in order to have data to export.
We need to tell the script what table to grab our data from. Since we are exporting contacts from our address book database we will use the table “addressbook” or whatever you feel like using.
Next we need to set up our query using the mysql_query() function. Our Query will be “select * from $table”, this will grab everything under the addressbook table. At the same time we will start an empty variable called $out, this will hold our data in a bit.
This is a quick and dirty little snippet. I had a case where I had to fill in a Subject Line and a message with only one multi line text box. It wasn’t practice to have a hard coded subject line as it would be the same for every message or in my base bug.
Have a look at the code, I will explain what is going on below.
< ?
// Get the message String
$rawString = $_POST['comments'];
// Split the string into pieces for processing
$pieces = explode("\n", $rawString);
// First element is the subject line
$subject = $pieces[0];
// Take the array, delete the first entry, So we can pass it to $message
$messagePieces = array_slice($pieces, 1);
// Replace the \n or add a <br /> if you like.
$message = implode("<br />", $messagePieces);
echo "Subject: ". $subject;
echo "<br />";
echo "Message: ". $message;
?>
<form action="<? echo $_SERVER['php_self'] ?>" method="post">
<textarea id="comments" name="comments">Your message</textarea>
<input name="send" type="submit" value="Send" />
</form>
cURL or Client URL Library is a very powerful tool, and its something that i recently had to use while working with two APIs one for Unfuddle and one for HelpSpot.
PHP supports libcurl, a library created by Daniel Stenberg, that allows you to connect and communicate to many different types of servers with many different types of protocols. libcurl currently supports the http, https, ftp, gopher, telnet, dict, file, and ldap protocols. libcurl also supports HTTPS certificates, HTTP POST, HTTP PUT, FTP uploading (this can also be done with PHP’s ftp extension), HTTP form based upload, proxies, cookies, and user+password authentication.
These functions have been added in PHP 4.0.2.
You can interact with most APIs using cURL, at first it seams intimidating but once you start to use it you become comfortable with the set up.
Lets get started by parsing an RSS feed.
When you first start to learn about Graphic design from a technical point you learn about Format. In graphic design there are many different file formats created by even more graphic editors. They all have there Pros and there Cons.
When you are working for the web you really only have three options: GIF, JPEG and PNG. They all server there purpose and are great at there jobs. The trick is to learn how each format can best to its job and when.
Read on..
I had a heck of a time finding a Regular Expression to parse URLs in a body of text. The beauty with this expression is its flexibility, it will handle a http or https url with or without www. and it’s fine with tinyurls.
// $subject contains a body of text with non html URLs
$text = ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]", "<a href=\"\\0\">\\0</a>", $subject);
This is posted more as a snippet because is spent so long trying to find one that would work.
$subject will be the body of text containing flat text urls. $text will now contain our information.
// Output New formatted content with links. echo $text;
Now our content is parsed with URLs.
Done!
This is a handy little Snippet that goes well with PHP Microtime. Not only are we concerned with our scripts execution time but we also want to make sure we are not using an exorbitant amount of memory in the process.
At the top of your script lets place the code that will start PHP’s Micro time.
$time_start = microtime(true);
At the bottom of your page, just before the “
” tag we will put the Code that will calculate the execution time as well as how much memory was used to execute the script.
// RENDER TIME $time_end = microtime(true); $time = $time_end - $time_start; echo "Loaded in \n"; echo round($time, 3)." Seconds <br />"; echo 'Peak: ' . number_format(memory_get_peak_usage(), 0, '.', ',') . " bytes\n <br />"; echo 'End: ' . number_format(memory_get_usage(), 0, '.', ',') . " bytes\n";
number_format() simply formats the number out put to look something like this “111,964″ instead of “111964″.
memory_get_peak_usage() is going to return a value based on the peak memory used during the execution. This is more so were we want to see improvements made.
memory_get_usage() will return the amount of memory used once the script is done processing, basically the amount currently used once the crunching is finished.
Its a good idea to think about memory usage when you are making web applications as this can impact your hosting.
Say you have a VPS server with 256mb of ram but the foot print of each user is 25mb you can can only have about 10 people accessing your site before you running server errors exceeding memory limits. Any work involving processing of images a lot of data manipulation can eat up memory in a hurry.
Not to long ago i made a tutorial on how to Creating Black and White Images in Photoshop CS3. This tutorial though centered around JPG was will an nondestructive method and has worked well for me in the past. But there are many methods in creating black and white images. Some involve a bit more understanding of colour and manipulating the colour channels in Photoshop. The method i have been using lately is done with RAW photos in Adobe Camera Raw 4.4.1.
I tried a few examples from the internet and neither seamed to work properly so i adapted the two that i found.
First things first:
Open your comments.php file and look for a line like this.
<li class="<?php echo $oddcomment; ?>" id="comment-< ?php comment_ID() ?>"> </li>
I was using this technique on my site for a while and realized that i actually liked the evening image you currently see in the header of my site.
The basic principle behind this tutorial is to allow a CSS file to be dynamic in the sense that it can use logic to define certain images or even colour schemes if you wish. The User will never see any JavaScrip so if they have Javascript dissabled your design will still come through.
For my example i used a div with the class of headerImage, simple enough. I then created a new PHP file and called it city.php.
If you try to include a a PHP file as a CSS link it will not work properly. You need to change the files header information.
we do this by using this line of code:
header("Content-type: text/css");