- Above the Fold: Understanding the Principles of Successful Web Site De
- Adapting to Web Standards
- Art of Non-Conformity
- Art of Readable Code
- Art of SEO
- Back to the User
- Beginning PHP6, Apache, MySQL Web Development
- Book Notes
- Books to Read
- Bored and Brilliant
- Born For This
- Choosing A Vocation
- Complete E-Commerce Book
- Content Inc
- Core PHP Programming
- CRM Fundamentals
- CSS Text
- Dealing with Difficult People
- Defensive Design for the Web
- Deliver First Class Web sites
- Design for Hackers: Reverse-Engineering Beauty
- Designing Web Interfaces
- Designing Web sites that Work: Usability for the Web
- Designing with Progressive Enhancement
- Developing Large Web Applications
- Developing with Web Standards
- Economics of Software Quality
- Effortless commerce with php and MySQL
- Epic Content Marketing
- Extending Bootstrap
- Foundation Version Control for Web Developers
- Guerrilla Marketing for a Bulletproof Career
- HACKING EXPOSED WEB APPLICATIONS, 3rd Edition
- Hacking Web Apps
- Happiness At Work
- Implementing Responsive Design
- Inmates Are Running the Asylum
- Instant LESS CSS Preprocessor How-to
- jQuery Pocket Reference
- Letting Go of the Words
- Lost and Found: A Painfully Honest Field Guide to the Startup World
- Making Every Meeting Matter
- Manage Your Day to Day
- Marketing to Millenials
- Mobile First
- Monster Loyalty
- More Eric Meye on CSS
- Official Ubuntu Book
- Organized Home
- Pay Me… Or Else!
- Perennial Seller
- Pet Food Nation
- PHP 5 E commerce Development
- PHP In a NutShell
- PHP Refactoring
- PHP5 and MySQL Bible
- PHP5 CMS Framework Development
- PHP5 Power Programming
- Preventing Web Attacks with Apache
- Pro PHP and jQuery
- Professional LAMP
- Purple Cow: Transform Your Business
- Responsive Web Design with HTML and CSS3
- Responsive Web Design with HTML5 and CSS3
- Rules of Thumb
- Saleable Software
- Search Engine Optimization Secrets
- Securing PHP Web Applications
- Serving Online Customers
- Simple and Usable Web, Mobile and Interaction Design
- Smart Organizing
- Smashing UX Design: Foundations for Designing Online User Experiences
- Studies in History and Philosophy of Science
- Talent is Not Enough
- The 10x Rule
- The Benefits of Working with Git In Your Software Projects
- The Clean Coder
- The Herbal Handbook for Home & Health
- The Life-changing Magic of Tidying up
- The Modern Web
- Think First
- This Is Marketing
- Traction
- Version Control with Git, 2nd Edition
- Web Analytics 2.0: The Art of Online Accountability and Science of Cus
- Web Site Usability: A Designer's Guide
- Web Word Wizardry
- Web Word Wizardy
- Website Owner’s Manual
- Whats Stopping Me
- Work for Money, Design for Love
- Your Google® Game Plan for Success: Increasing Your Web Presence with
- Checklists I Have Collected or Created
- Crafts To Do
- Database and Data Relations Checklist
- Ecommerce Website Checklist
- Learning Stuff From Blogs
- My Front End UI Checklist
- New Client Needs Analysis
- Newsletters I Read
- Puzzles
- Style Guides
- User Review Questions
- Web Designer's SEO Checklist
- Web site Review
- Website Code Checklist
- Website Final Approval Form
- Writing Content For Your Website
- Writing Styleguide
- Writing Tips
- 7 essentialls of graphic design
- Accidental Creative
- Choosing the right color for your logo
- CMS Design
- Communicating Design: Developing Web Site Documentation for Design and
- Designing for Web Performance
- Eat That Frog
- Elements of User Experience
- Flexible Web Design
- Forms that Work: Designing Web Forms for Usability
- Homepage Usability
- Responsive Web Design
- Seductive Interaction Design: Creating Playful, Fun, and Effective Use
- Strategic Web Designer
- Submit Now: Designing Persuasive Web sites
- The Zen of CSS Design
- Complete Book of Potatoes
- Creating Custom Soil Mixes for Healthy, Happy Plants
- Edible Forest Garden
- Garden Design
- Gardening Tips and Tricks
- Gardens and History
- Herbs
- Houseplants
- Light Candle Levels
- My Garden
- My Garden To Plant
- Organic Fertilizers
- Organic Gardening in Alberta
- Plant Nurseries
- Plant Suggestions
- Planting Tips and Ideas
- Root Cellaring
- Things I Planted in My Yard
- Way We Garden Now
- Weed Decoder
- 101 Organic Gardening Hacks
- 2015 Herbal Almanac
- Beautiful No-Mow Lawns
- Beginner's Guide to Heirloom Vegetables
- Best of Lois Hole
- Design in Nature
- Eradicate Invasive Plants
- Gardening Books to Read
- Gardens West
- Grow Organic
- Grow Your own Herbs
- Guerilla Gardening
- Heirloom Life Gardener
- Hellstrip Gardening
- Indoor Gardening: The Organic Way
- Landscaping with Fruits and Vegetables
- Real Gardens Grow Natives
- Seed Underground
- Small plot, high yield gardening
- Thrifty Gardening from the Ground Up
- Vegetables
- Veggie Garden Remix
- Weeds: In Defense of Nature's Most Unloved Plants
- What Grows Here
- Activities for Kids
- Animals In My Yard
- Baking & Cooking Tips
- Bertrand Russell
- Can I Get that on Sale?
- Cleaning Tips and Tricks
- Colour Palettes I Like
- Compound Time
- Cooking Tips
- Crafts
- Crafts for Kids
- Household Tips
- Inspiration
- Interesting
- Interior Design
- Keywording & Tags
- Latin Phrases
- Laundry Tips
- Learn Something New
- Links, Information, and Cool Videos - Stuff for My Kids
- Music Websites for Parents and Kids
- My Miscellany
- Organizing
- Quotes
- Reading List
- Renovations
- Silly Sites
- Things that Make Me Laugh
- Videos to Watch
- Ways to Be Nice
- YouTube Hacks
- Bug Tracking Tool
- Business Tips
- Code Packages I Like on GitHub
- Content Management systems
- Creating Emails & Email Newsletters
- Games
- I Made A Framework
- Open Source
- Patterns, Textures and other media
- PHP Coding Standards
- Programming
- Project Verbs for to do lists
- Qualities of Creative Leaders
- Scalable Vector Graphics
- SEO
- Software Design
- The Shell, Scripts and Such
- Writing Instructions
- Accessibility
- CSS Frameworks
- CSS Reading List
- CSS Sticky Footer
- Design of Sites
- htaccess files
- HTML Tips and Tricks
- Javascript (and jQuery)
- Landing Page Tips
- Making Better Websites
- More Information on CSS
- MySQL and Databases
- Navigation
- Responsive Design
- Robots.txt File
- Security and Secure Websites
- SVG Images
- Types of Content
- UI and UX and Design
- Web Design and Development
- Web Design Tools
- Web Error Codes
- Website Testing Checklist
- Writing for the Web
- Writing Ideas for your website
- Animations and Interactions
- Being a Better Designer
- Bootstrap Resources
- Color in Web Design
- Colour
- CSS Preprocessors: Sass and Less
- CSS Tips Tricks
- Customer Centered Design Myths
- Design Systems
- Designing User Interfaces
- Font & Typographical Inspiration
- Fonts, Typography, Letters & Symbols
- Icons
- Logo Designs
- Photoshop Tips and Tricks
- Sketch
- UX and UI and Design Reading List
- Web Forms
- Well Designed
I enjoyed PHP in a NutShell. However, much of the information is now dated. Here is what is still relevant.
Highlight parts of a string.
$mystr = 'var_dump($foo); ?>';
highlight_string($mystr);
file_put_contents("highlighter.php", $mystr);
highlight_file("highlighter.php");
As you can see, that passes the string into highlight_string( ), then saves it out as highlighter.php and passes that filename into highlight_file( ) to print out again. Both highlight_string( ) and highlight_file( ) can take a second parameter, which, if set to true, will make these functions return the highlighted HTML rather than print it out directly, giving you more control over it.
The two key functions here are highlight_file( ) and highlight_string( ), although there is also a function show_source( ) that is an alias to highlight_file( ). This takes a filename as its parameter and outputs that file to the screen, with all keywords, strings, numbers, and functions highlighted in various colours, as shown in Figure 22-1. The highlight_string( ) function is almost identical, except it takes a string as its parameter.
Used for renaming and moving files, rename( ) takes two parameters: the original filename and the new filename you wish to use. The function can rename/move files across directories and drives and return true on success or false otherwise.
Here is an example:
$filename2 = $filename . '.old';
$result = rename($filename, $filename2);
if ($result) {
print "$filename has been renamed to $filename2.\n";
} else {
print "Error: couldn't rename $filename to $filename2!\n";
}
Creating a PDF document is similar to creating a picture in that, to get the desired result, you state the list of drawing actions required to get there—drawing lines, text, adding fonts, etc. You need to track the PDF document you are working with at all times because other PDF functions use it.
Even creating a simple PDF takes quite a few functions; this next code block does comparatively little:
$pdf = pdf_new( );
pdf_open_file($pdf, "/path/to/your.pdf");
$font = pdf_findfont($pdf, "Times-Roman", "host");
pdf_begin_page($pdf, 595, 842);
pdf_setfont($pdf, $font, 30);
pdf_show_xy($pdf, "Printing text is easy", 50, 750);
pdf_end_page($pdf);
pdf_close($pdf);
pdf_delete($pdf);
Starting at line one, we use pdf_new( ) to create a new PDF document and store it in $pdf. This value will be used in all the subsequent functions, so it is important to keep.
The pdf_open_file( ) function is used to open a file for writing. Note that the free version of PDFlib does not alter existing PDFs; this function merely creates a new PDF of the given filename. Naturally, it will need to be somewhere your web server can write to; otherwise, you will receive an error along the lines of "Fatal error: PDFlib error: function 'PDF_set_info' must not be called in 'object' scope in yourscript.php on line XYZ."
The next line uses pdf_findfont( ) to find and load a font for use inside the generated PDF file. In the example, pdf_findfont( ) takes three parameters—the PDF document to work with, the font's name to use, and which encoding to use. In the example above, $pdf is specified as the first parameter (as always). "Times-Roman" is specified as the font to use, one of the 14 standard internal PDFlib fonts. The next parameter can be set to either "winansi" (Windows), "macro man" (Macintosh), "ebcdic" (EBCDIC code page 1047 machines), "builtin" (for symbol fonts), or "host" (winansi for Windows, macroman for Macintosh, etc.; recommended).
When successful, pdf_findfont( ) returns a font resource which is stored in $font. You may wish to add error checking in your own scripts for extra reliability.
At this point, we're ready to start on the main part of PDF generation. The first three lines merely set things up for the document. The next four—lines four to seven—are the page itself. Reading the source should be easy to see that line four and line seven encapsulate one page in the generated PDF file. Objects and text outputted between a pdf_begin_page( ) and pdf_end_page( ) will affect that page, and multiple begin/end blocks are used to create multiple pages.
Note that pdf_begin_page( ) takes a second and third parameter: the X and Y point size. The PDF format allows you to make your pages different point sizes from page to page, but you will most often want to choose one size and stick with it.
You need to pass three parameters to pdf_setfont( ): the first is the PDF resource, as usual; the second parameter is the return value from pdf_findfont for the font you wish to use; and the final parameter is the size to use, in points. Immediately afterward, we call pdf_show_xy( ) to place text into our page. Parameter two of pdf_show_xy( ) is the string to use, and parameters three and four are the X and Y coordinates to print the text.
The last parameter passed to pdf_show_xy( ) is when the text should appear above the page baseline in points. That is, setting this parameter to 0 will have the bottom of a lowercase "a" at the very bottom of the page and the bottom of a lowercase "y" outside the margins of the page.
With pdf_end_page( ) called, the first and only page is completed, and all that is left to do is clean things up. This is done through the help of two functions, which are pdf_close( ) and pdf_delete( ). They may sound somewhat similar, but you do need to call them both: pdf_close( ) cleans up the PDFlib memory and document-related resources, whereas pdf_delete( ) cleans up PHP's reference to $pdf and any other internal resources. Be sure to call them in the order shown above.
When you run that script through your web browser, you won't see any "Success!" message printed out. However, you should find your PDF file created and viewable in your PDF reader of choice.
Bibliographical Information
PHP in a Nutshell:A Desktop Quick Reference
By Paul Hudson
Publisher: O'Reilly Media
Release Date: June 2009
Further Reading
SVG Unleashed by Andrew Watt and Chris Lilley (Sams)
This book doesn't cover SVG. But if you want to know more about XML this is the first place to look.
Unix Shell Programming by Stephen Kochan and Patrick Wood (Sams)
General Unix and C programming is very similar to PHP, so you can learn a lot about PHP by learning about the Unix shell.
* PHP Builder (http://www.phpbuilder.com) publishes a number of high-quality PHP tutorials each year, and also has very active forums full of people ready to help.
* All the content at http://www.cookiecentral.com. is available for free, and there is also an active messageboard for you to ask questions or see what others are saying.
* Don't try to remember all the ASCII codes—you can find them online at http://www.asciitable.com.
* Finally, if all else fails and you're still hunting around, you can visit my personal website at http://www.hudzilla.org, where I keep my own brand of PHP help.
* PHP Architect http://www.phparch.com
These are notes I made after reading this book. See more book notes
Just to let you know, this page was last updated Thursday, Oct 03 24