Nic Shulver, Other Useful PHP Bits More Useful PHP Read the contents list in the PHP online manual You will find loads of interesting.

Slides:



Advertisements
Similar presentations
Don’t Type it! OCR it! How to use an online OCR..
Advertisements

B2PDF b2pdf is the new and innovative release of our powerful command line tool for PDF customization b2pdf is a robust stand alone PDF file generation.
The Keys to Speed. File Extensions Definition A tag of three or four letters, preceded by a period, which identifies a data file's format or the application.
Chapter 4 Adding Images. Inserting and Aligning Images Graphics refer to the appearance of most non- text items on a web page, such as: – Photographs.
Iframes & Images Using HTML.
Web Site Development Test 2 Working in DreamWeaver.
Add Images to Improve Your Presentation Day 8. You will learn to Understand Graphics Formats Find Graphics Create Your Own Images Insert an Image on Your.
Technical Tips and Tricks for User Support Mike Gardner
1 of 6 This document is for informational purposes only. MICROSOFT MAKES NO WARRANTIES, EXPRESS OR IMPLIED, IN THIS DOCUMENT. © 2007 Microsoft Corporation.
Python and Web Programming
2.01 Understand Digital Raster Graphics
® Microsoft Office 2010 PowerPoint Tutorial 2: Adding and Modifying Text and Graphic Objects.
Unit 2, Lesson 5 Website Development Tools AOIT Web Design Copyright © 2008–2012 National Academy Foundation. All rights reserved.
8/16/2015alicewebmaster1 Create contents with the new Content Management System (Drupal): Workflow for page editors.
Chapter 3 Adding Images in HTML. Agenda Understanding Web Page Images Prepare Your Images for the Web Insert an Image Specify an Image Size Add Alternative.
Tutorial 3: Working with Images. Objectives Session 3.1 – Identify the differences among image file types – Evaluate the purpose of alternative text –
Prepared by George Holt Digital Photography BITMAP GRAPHIC ESSENTIALS.
M. Taimoor Khan * Java Server Pages (JSP) is a server-side programming technology that enables the creation of dynamic,
Introduction to the Enterprise Library. Sounds familiar? Writing a component to encapsulate data access Building a component that allows you to log errors.
Project Four Forms Discuss form processing Describe the difference between client-side and server-side form processing Add a horizontal rule to a Web page.
Making an HTML Document Notepad Group Bo Kim Dan Carter Han Chong Justin Weaver Kris Lamont.
Nic Shulver, Intro: Developing Server Applications What is a server? Many types of server – File server – file: networked file.
Nic Shulver, Retrieving Stored Data Introduction This set of slides shows: The information source database structure The data.
Unit E. Image Measurements The size of an image can be measured 2 ways: Dimensions: the height and width, measured in pixels. File Size: measured in Kilobytes.
Setting up a simple Web Page Anatomy of posting some text and images using a simple text editor and some raw HTML code – the cheap way to create a web.
.  Entertain  Inform  Educate  Blogs  Sell  Date  Gamble  Religion.
Nic Shulver, Intro: Developing Server Applications What is a server? Many types of server – File server – file: networked file.
XHTML Images. Images are important Purpose: to enhance your web site. Add only when they complement or add additional impact to your message.
Images in web pages. Images Why do we use images? They add interest, and keep the user from being bored They convey information –Charts are easier to.
Applets Chapter 17.  Java’s big splash onto the scene came in the mid 90’s. The people at Sun Microsystems had managed to work java programs into Web.
Creating Web Pages with Links, Images, and Formatted Text
Tutorial 7 Creating Forms. Objectives Session 7.1 – Create an HTML form – Insert fields for text – Add labels for form elements – Create radio buttons.
1.Getting Started 2.Modifying Design 3.Page 4.News 5.Events 6.Photo Gallery 7.Newsletter Index Training 15 th Mar., 2011.
ImageJ EE4H, M.Sc Computer Vision Dr. Mike Spann
Creating Dynamic Web Pages Using PHP and MySQL CS 320.
HTML Authoring. Design  A good website starts its life in the design stage Layout, Color, Sound, Content, Functionality and Maintainability aspects are.
Learning HTML Presented By: Wayne Helle What Is HTML? Learning Basic Tags... Formating Your Text... Working With Images and Links... Simple Form Boxes..
Copyright (c) 2004 Prentice-Hall. All rights reserved. 1 Committed to Shaping the Next Generation of IT Experts. Adding Graphical Elements Essentials for.
audio video object Options: controls autoplay Need to define height and width Options: controls autoplay.
2010/11 : [1]Building Web Applications using MySQL and PHP (W1)Graphics.
Microsoft FrontPage 2003 Illustrated Complete Creating a Form.
Multimedia. What is a graphic?  A graphic can be a: Chart Drawing Painting Photograph Logo Navigation button Diagram.
The Web Wizard’s Guide to HTML Chapter Three Colors, Patterns, and Inline Graphics.
Web Design and Development. World Wide Web  World Wide Web (WWW or W3), collection of globally distributed text and multimedia documents and files 
Exploring Web Design Chapter 1. Objectives Develop a new perspective of the WWW Learn what makes a website good or bad Discover how to apply objective.
1 2/22/05CS120 The Information Era Chapter 4 Basic Web Page Construction TOPICS: Images and placing pages on the server.
Slide 1 Graphics (Characteristics 1) Images have various characteristics that affect performance Size (number of pixels) – Large images can be several.
Nic Shulver, Storing Data on the Server Introduction We are going to look at some working code It writes fixed data into a simple.
 Before you continue you should have a basic understanding of the following:  HTML  CSS  JavaScript.
CHAPTER 7 LESSON C Creating Database Reports. Lesson C Objectives  Display image data in a report  Manually create queries and data links  Create summary.
Dr. Abdullah Almutairi Spring PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages. PHP is a widely-used,
XP New Perspectives on Macromedia Dreamweaver MX 2004 Tutorial 5 1 Adding Shared Site Elements.
HTML5 and CSS3 Illustrated Unit F: Inserting and Working with Images.
13 June – Session : Graphics Different types of Graphics for the web Features of image editing software Good practice for image editing.
XP Creating Web Pages with Microsoft Office
PHP using MySQL Database for Web Development (part II)
2.01 Understand Digital Raster Graphics
File Formats Different applications (programs) store data in different formats. Applications support some file formats and not others. Open…, Save…, Save.
2.01 Understand Digital Raster Graphics
Weebly Elements, Continued
2.01 Understand Digital Raster Graphics
On each booth you will find 4 to 6 banners
Chapter 4 Adding Images.
Image Asset Vector Asset
Graphics (Characteristics 1)
2.01 Understand Digital Raster Graphics
Working with images EIT, Author Gay Robertson, 2018.
Tutorial 6 Creating Dynamic Pages
HTML Introduction Lecture 8.
2.01 Understand Digital Raster Graphics
Presentation transcript:

Nic Shulver, Other Useful PHP Bits More Useful PHP Read the contents list in the PHP online manual You will find loads of interesting functions Using include() and require() The dirname(__FILE__) trick PDF writing through a free add-on library getimagesize() The mail() functions

Nic Shulver, Other Useful PHP Bits Using include() and require() Examples of PHP’s “file insertion” command include(“myStandardHeader.inc”); include(“/root/subdir/library/visaPayments.php”); include(“../libs/MyGraphix.php”); The “included” file is effectively added into your source code at the line where the “include()” command is issued The “require()” command is identical except that if it fails (example: no such file) then PHP stops with an error

Nic Shulver, Other Useful PHP Bits The dirname(__FILE__) trick The value __FILE__ (double underscore at beginning and end) is provided for you by PHP It’s a kind of run-time “constant” and it is the full filename of your script For example, it had the value: “c:\Inetpub\wwwroot\phpTest\writePDF\writePDF.php” for a PDF-writing test script on a staff machine The command dirname(__FILE__) returns something like: “c:\Inetpub\wwwroot\phpTest\writePDF”

Nic Shulver, Other Useful PHP Bits Why use dirname(__FILE__)? Very useful when you need the path to your local directory (handy for database driver initialisation) Useful if you ever expect to change the directory your code works from By moving development code into a production server Or by changing your directory tree Why not just use __DIR__ ? This is a replacement for dirname(__FILE__) Appeared in PHP (released late 2008)

Nic Shulver, Other Useful PHP Bits PDF writing Free and commercial PDF libraries available Simple, easy to use free library is FPDF (Free PDF) at Tutorials at Online documentation at Downloads at The example on the next slide was generated with the FPDF library

Nic Shulver, Other Useful PHP Bits

<?php require('/Inetpub/wwwroot/phpLib/fpdf.php'); $pdf=new FPDF(); $pdf->AddPage(); $pdf->Image('exLogo.png',10,8);// Adds a "Corporate Logo" // Bit of text under the logo $pdf->SetFont('Courier','',8); $pdf->Ln(20); $pdf->Cell(64, 10, 'All rights reserved (c)2005 The RealBig Corporation.',0,1); // main chunks of text $pdf->SetFont('Helvetica','B',16); $pdf->Write(0,'Hello World!'); $pdf->Ln(8); $sExampleText = "This PDF is generated by ". __FILE__. "! Example "; $pdf->SetFont('Times','',12); $pdf->Write(5, $sExampleText. "1...\n"); $pdf->Write(5, $sExampleText. "2...\n"); $pdf->Write(5, $sExampleText. "3...\n");

$pdf->Write(5, $sExampleText. "4...\n"); $pdf->Write(5, $sExampleText. "5...\n"); $xpos = $pdf->GetX();// draws a mid-blue horizontal line 100 units long $ypos = $pdf->GetY(); $pdf->SetDrawColor(128, 128, 255); $pdf->Line($xpos,$ypos, $xpos+100,$ypos); $pdf->Write(8, $sExampleText. "6...\n"); $pdf->Write(10, $sExampleText. "7...\n"); $pdf->Write(12, $sExampleText. "8...\n"); // draws an orange box with a mid-red border, 100 units wide and 25 units high $xpos = $pdf->GetX(); $ypos = $pdf->GetY(); $pdf->SetDrawColor(255, 80, 80); $pdf->SetLineWidth(0.75); $pdf->SetFillColor(248, 191, 46); $pdf->Rect($xpos,$ypos, 100,25, 'DF'); $pdf->Output(); ?>

Nic Shulver, Other Useful PHP Bits The getimagesize function Sometimes you need to check the size of an image before using it For example, a photo gallery service might allow users to upload and view images Good to check image size and scale appropriately for images that exceed predetermined limits Could be used to help scale images for thumbnails getimagesize() returns a four-element array (or list)

Nic Shulver, Other Useful PHP Bits The getimagesize function You can use this kind of code for easy access: list($width, $height, $type, $attr) = getimagesize("exLogo.png"); $width and $height contain just what you would expect $type holds a number giving information about the image format (GIF, JPG, PNG, SWF, SWC, PSD, TIFF, BMP, IFF, JP2, JPX, JB2, JPC, XBM, or WBMP) – for example, PNG gives a value of 3 $attr holds part of an HTML image tag, for example: width="320" height="64"

Nic Shulver, Other Useful PHP Bits The postman only knocks once... This simple code may be used to send messages: Note this only works if the PHP server also has a mail server running – you’d have to check with the administrator

Nic Shulver, Other Useful PHP Bits There’s much more out there! We have looked at a few interesting areas: Using include() and require() to add blocks of code into our PHP – great for modularity and re-use The dirname(__FILE__) trick that helps us find where we are on the server PDF writing through a free add-on library, including bitmapped graphics and simple vector graphics The getimagesize() for dynamically determining the size of an image in one of a dozen or more formats The mail() function – it depends on other resources and it is not very efficient, but it is very easy to use