-
Problems
This line enable URL Rewriting . It must be enabled via the RewriteEngine directive! and if your .htaccess file is going to use rewrite rules, you should always include this line. Otherwise, you can’t be sure if its enabled or not. The string “on” is case insensitive.
image in your html code
The GD Extension
Before you can start generating images with PHP, you need to check that you actually
have image-generation capabilities in your PHP installation. In this chapter we’ll
discuss using the GD extension, which allows PHP to use the open source GD graphics
library available from http://www.boutell.com/gd/.
Load the familiar phpinfo( ) page and look for a section entitled “GD”. You should
see something similar to the following.
gd
GD Support enabled
GD Version 2.0 or higher
FreeType Support enabled
FreeType Linkage with freetype
JPG Support enabled
PNG Support enabled
WBMP Support enabled
Pay close attention to the image types listed. These are the types of images you will
be able to generate.
There have been three major revisions of GD and its API. Versions of GD before 1.6
support only the GIF format. Version 1.6 and later support JPEG, PNG, and WBMP,
but not GIF (the GIF file format uses patented algorithms that require royalties). Version
2.x of GD added several new drawing primitives.
All GD 1.x versions are limited to 8-bit color. That is, the images you generate or
manipulate with GD 1.x can contain only 256 different colors. For simple charts or
graphs this is more than sufficient, but if you are dealing with photos or other images
with more than 256 colors you will find the results less than satisfactory. Upgrade to
GD 2.x to get true-color support, or use the Imlib2 library and corresponding PHP
extension instead.
You can also check for php_gd in your php extension.
INTEGRATION OF PHP IMAGE IN YOUR HTML CODE:
To embed a PHP-generated image in an HTML page, pretend that the PHP script that
generates the image is actually the image. Thus, if we have image1.php and image2.
php scripts that create images, we can modify the previous HTML to look like this:
<html>
<head>
<title>Example Page</title>
</head>
<body>
This page contains two images.
<img src="image1.php" alt="Image 1">
<img src="image2.php" alt="Image 2">
</body>
</html>
Instead of referring to real images on your web server, the img tags nowrefer to the
PHP scripts that generate the images.
Furthermore, you can pass variables to these scripts, so instead of having separate
scripts to generate the two images, you could write your img tags like this:
<img src="image.php?num=1" alt="Image 1">
<img src="image.php?num=2" alt="Image 2">
.
No comments:
Post a Comment