| |||||||||||
| |||||||||||
Using PHP to output images, XML, Style sheets, etc
PHP is usually used to generate a stream of HTML to be sent to the browser, but if you use the header function within your page you can use it to send any other type you wish. For example, if I include
header("Content-type: image/jpeg"); then I can script the production of images. Easy? Yes, but two words or caution: a) The header call must be included within your script before it generates a single byte of output. Rephrasing that, the < character of the initial <?php must be on the very first line and in the very first column of your script, and not a single byte may be output until you've made the header call. b) If you select a format such as jpeg to send out, it's your responsibility to ensure that it's a valid jpeg image stream. More often than not, you'll do this with the Gd library, but if you're using PHP simply to upload images and manage their storage, that's not necessary. We have an example script to upload, store and retrieve images in a database in our solution centre. (written 2006-01-15 12:44:49) Associated topics are indexed under H112 - PHP - Further Web Page and Network HandlingW704 - Web and Intranet - Cascading style sheets - putting it all together H118 - Generating CSS through PHP
Some other Articles
Instructions for bright peopleNB ''Aspiration'' Combining similar rows from a MySQL database select May all your screw-ups be big ones Using PHP to output images, XML, Style sheets, etc Open Source training from Well House Consultants Merging pictures using PHP and GD Smoke and mirrors Python's Generator functions The fencepost problem 1638 posts, page by page
Link to page ... 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33 at 50 posts per pageThis is a page archived from The Horse's Mouth at http://www.wellho.net/horse/ - the diary and writings of Graham Ellis. Every attempt was made to provide current information at the time the page was written, but things do move forward in our business - new software releases, price changes, new techniques. Please check back via our main site for current courses, prices, versions, etc - any mention of a price in "The Horse's Mouth" cannot be taken as an offer to supply at that price. Link to Ezine home page (for reading). Link to Blogging home page (to add comments). |
| ||||||||||
PH: 01144 1225 708225 • FAX: 01144 1225 707126 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho | |||||||||||