After you downloaded MAMP, it created a folder inside the program called ‘htdocs’. In order to run the code, we need to display it in a browser. In this case, we’re also using an echo statement in PHP to display a string “this is some code.”Īfter you’ve written your code, the file name should be changed to indicate that there is PHP to be read ( ex. The tags indicate that the machine that it should read PHP and each statement within should end with a. PHP can be placed anywhere, but in the above example, PHP, is inserted in the body of the page, between tags. For those that aren’t: the first few lines are defining the document type and page content. I use Sublime Text- but feel free to utilize your preferred program.įor anyone familiar with HTML, you should notice the HTML declaration and tags. In the meantime, fire up your text editor – we’re going to write our first line of code. MAMP will also automatically load a page in your web browser. It may take up to a few minutes for your servers to be ready – you’ll know they are ready when the boxes next to “Apache Server” and “MySQL” are filled in. (I told you, they really want you to use MAMP PRO) Let’s get our server fired up by clicking “Start Servers”. The control panel will give you a few options: Preferences, Start Servers, Quit and Try MAMP PRO. (It might pressure you to use MAMP PRO – we’re fine with MAMP for now. (There are other functions like a MYSQL server, but for now I’ll focus on how we’ll use it for PHP.)Īfter it is downloaded, open the application to run it. This is available free for download and allows you to run a server from your machine. The easiest way for us to do this is to utilize a package that allows you to manage your websites locally called MAMP (alternatively there is WAMP for Windows users – this can be downloaded at the same source here). How to create stuff using PHP:īecause your code needs to run off a server, you have two options: utilize the server space you may have (if you have taken Clio 2 or rented space for this purpose), or you can run a server off of your own computer. Rather than producing HTML page that contains every quote, Heppler has encoded the page to pull a quote from his database each time the page is refreshed. The project demonstrates a significant feature of the PHP functionality: your server will evaluate the page before it is generated in a browser. Heppler provides the files for this project (his index.php and the. Each time you visit the page, a new quote is drawn from a database of definitions Heppler created (These quotes were collected from Day of DH participants between 2009-2012). Jason Heppler demonstrates the functionality of PHP in his somewhat tongue-in-cheek website “ What is Digital Humanities“. Further, embedding it in HTML means that regular webpages can be dynamic and do things like run data calculations from the website.įurther information available in the PHP documentation. In particular, PHP works well with MYSQL as we will look at below. Because PHP runs on a server, it has access to the files and content within that database. PHP, on the other hand, is a “ server-side language” meaning the files and content are processed at the server that holds them and then sent to your computer browser. Though the syntax for PHP will be similar to what we saw with JavaScript, the languages boast differences in functionality. JavaScript for instance runs in a browser (think of how we ran our code in a browser window earlier in the semester). Maintaining the initial acronym, PHP now refers to a “ recursive acronym for… Hypertext Preprocessor“.īoth of these are meant to emphasize that PHP is distinct in the way that it handles website data. Initially interested in tracking visits to his site, the scripts that would become a language were referred to as, “ Personal Home Page tools.” These were expanded in subsequent versions (between 1994 to 2004) and the current form is known as PHP 5. PHP got its name from creator Rasmus Lerdorf. For these reasons it is used across the internet and with some of the most recognizable sites (Facebook and WordPress, for instance.) It is easily embedded in HTML and works well with databases. PHP is an open source scripting language that is built for a web environment and runs on a computer server. This is by no means a full engagement with the capabilities of the language and anyone interested in learning PHP should access the documentation and other resources described below. This tutorial is meant to introduce Clio 3 students to PHP and to point out some of its useful features.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |