国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

Home Backend Development PHP Tutorial Graphic button created by passing text_PHP tutorial

Graphic button created by passing text_PHP tutorial

Jul 21, 2016 pm 04:02 PM
h php transfer create graphics button letter of English detailed illustrate pass

通過文字傳遞創(chuàng)建的圖形按鈕,詳細(xì)說明請看文內(nèi)英文說明
????/* PHP3 Button generator, (c) 2000 by IzzySoft (izzysoft@buntspecht.de)
????* License: GPL (and it would be nice to drop me a note that you find it
????* useful - if you use it. And, of course, I am very interested in
????* enhancements you made to the script!
????*
????* Purpose: generate buttons with text passed by parameter.
????*
????* possible parameters to the script:
????*button- input gif image. Just the part of the filename before the dot.
????*The specified image file is expected in the same directory
????*as this script resides in.
????*font - font to use (1 - 5; 1 is very small, 3 medium, 5 normal size.
????*The script will automatically use a smaller font if text is
????*too long for selected size.) Default: 5
????*text - the text to be put on the button. Will be centered.
????*textcolor - color for the letters. Default: white.
????*in this example code only blue, white and black are defined;
????*but you can add custom colors easily.
????*width,heigth - width and heigth of the button. Useful only if target
????*button should have different size than source image.
????*
????* Example for usage:
????*
????* will look for yellow.gif and put the string "Example" on it.
????*
????* I use to have three buttons I normally generate (one displays selected
????* item, one is for mouseover(), and one is the default button). The source
????* images are yellow.gif, white.gif and blue.gif - so my script assumes
????* blue.gif as default if "button=" not specified - you may wish to change
????* this below, it's easy ;)
????*/
????// ===========================[ check fo
????//?????r parameters and/or set defaults ]===
????if (($font == "") || ($font > 5) || ($font < 1)) { $font = 5; }
????if ($text == "") { $text="Moin!"; }// button text
????if ($textcolor == "") {// color for the letters
????switch ($button) {
????case "yellow":
????case "white":
????$textcolor = "black";
????break;
????default:
????if ($button == "") { $button = "blue"; }
????$textcolor = "white";
????break;
????}
????} // textcolor end
????$im_info = getimagesize("$button.gif"); // button size
????if ($width == "") {
????if ($im_info == "") {
????$buttonwidth = 125;
????} else {
????$buttonwidth = "$im_info[0]";
????}
????} else {
????$buttonwidth = $width;
????}
????if ($heigth == "") {
????if ($im_info == "") {
????$buttonheigth = 30;
????} else {
????$buttonheigth = "$im_info[1]";
????}
????} else {
????$buttonheigth = $heigth;
????}
????$vmidth = ceil($buttonheigth / 2);
????// =====================================
????//?????===[ now lets define some colors ]===

????$white = "255,255,255";
????$black = "0,0,0";
????$blue = "0x2c,0c6d,0xaf";
????// =====================================
????//?????=============[ build color array ]===
????// now we put the needed color into an a
????//?????rray (if e.g. "$textcolor=white",
????// the array $textcolor_array represents
????//?????"white")
????$textcolor_array = explode(",", $$textcolor);
????// =======================[ calculate po
????//?????sition of the text on the button ]===
????do {
????$textwidth = strlen($text) * imagefontwidth($font);
????$x = ($buttonwidth - $textwidth) / 2; $x = ceil($x);
????$y = $vmidth - (imagefontheight($font) / 2);
????$font--;
????} while (($x < 0) && ($font > 0)); $font++;
????// =====================================
????//?????======[ now we create the button ]===
????if (isset($width) || isset($heigth)) {// size change expected?
????$ima = imagecreatefromgif("$button.gif");// open input gif
????$im = imagecreate($buttonwidth,$buttonheigth); // create img in desired size
????$uglybg = ImageColorAllocate($im,0xf4,0xb2,0xe5);
????ImageRectangle($im,0,0,$buttonwidth,$buttonheigth,$uglybg);
????$dummy = imagecopyresized($im,$ima,0,0,0,0,$buttonwidth,$buttonheigth,$im_info[0],$im_info[1]);
????if ($dummy == "") {
????ImageDestroy($im); // if it didn't work, create default below instead
????} else {;}
????ImageDestroy($ima);
????ImageColorTransparent($im,$uglybg);
????} else {
????$im = imagecreatefromgif("$button.gif");// open input gif
????}
????if ($im == "") { $im = imagecreate($buttonwidth,$buttonheigth); // if input gif not found,
????$rblue = ImageColorAllocate($im, 0x2c,0x6D,0xAF);// create a default box
????ImageRectangle($im,0,0,200,100,$rblue);
????}
????$color = ImageColorAllocate($im, $textcolor_array[0], $textcolor_array[1], $textcolor_array[2]); // allocate the color
????imagestring($im, $font, $x, $y, "$text", $color); // put the text on it
????ImageGif($im);// send button to browser
????ImageDestroy($im);// free the used memory
?????>?????????

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/316427.htmlTechArticle通過文字傳遞創(chuàng)建的圖形按鈕,詳細(xì)說明請看文內(nèi)英文說明 ?php Header( Content-type: image/gif); // info for the browser /* PHP3 Button generator, (c) 2000 by Izz...
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PHP Installation on Linux PHP Installation on Linux Jul 18, 2025 am 04:30 AM

There are two main ways to install PHP on Linux: use package manager to install and source code to compile and install. For newbies or users who do not have special requirements for the version, it is recommended to use a package manager to install it. For example, running sudoaptupdate and sudoaptinstallphp on Ubuntu/Debian. On CentOS, you can first install the EPEL source and then install it with yum. After the installation is completed, you can verify through php-v and install common extensions. If you need a specific version or custom function, you should choose source code compilation and installation. The specific steps include downloading the source code package, decompression, and configuration (such as ./configure--prefix=/usr/local/php--with-co

PHP Syntax Basics PHP Syntax Basics Jul 18, 2025 am 04:32 AM

To learn PHP, you need to master variables and data types, control structures, function definitions and call specifications, and avoid common syntax errors. 1. Variables start with $, case sensitive, and types include strings, integers, booleans, etc.; 2. The control structure supports if/else/loop, and the template can use colon syntax instead of curly braces, foreach can handle arrays conveniently; 3. Functions are defined with function, supporting default parameters and variable parameters; 4. Common errors include missing semicolons, confusion == and ===, splicing characters errors, and improper use of array subscripts.

PHP Multiline Comments: A Quick Guide PHP Multiline Comments: A Quick Guide Jul 18, 2025 am 04:34 AM

Yes,PHPsupportsmultilinecommentsusingthe/.../syntax.Towritethem,enclosetextbetween/and/,whichcanspanmultiplelinesandisignoredbytheinterpreter.Theyareidealforlongexplanations,disablingcodeblocksduringtesting,oraddingfileheaders.Avoidnestingthem,asitbr

Documenting PHP with Comments Documenting PHP with Comments Jul 18, 2025 am 04:34 AM

When writing PHP comments, you should clarify the purpose, logic and structure. 1. Each function and class uses DocBlock format to explain the role, parameters and return values; 2. Explain "why" in the key logic rather than just "what was done"; 3. Add a brief description at the top of the file, including functions, dependencies and usage scenarios; 4. Avoid nonsense comments, add only necessary instructions before complex logic, and do not record the modification history. This improves code readability and maintenance efficiency.

Hello, PHP! Hello, PHP! Jul 18, 2025 am 04:35 AM

Of course it is useful. PHP still plays an important role in web development, especially for CMS and e-commerce platforms. 1. The threshold for PHP is low, the syntax is intuitive, and suitable for beginners to get started; 2. It is widely used in dynamic web development, such as user login, form submission and other functions; 3. It can build an API interface, which is more efficient with the Laravel framework; 4. It supports CMS customization, such as WordPress plug-in and theme development; 5. It can write automated task scripts, such as data crawling and report generation; 6. Learning suggestions include mastering basic syntax, combining database exercise projects, using mainstream frameworks, focusing on security defense and referring to open source projects. PHP is highly practical and has a mature ecological environment, and is still widely used in small and medium-sized projects.

Mastering PHP Block Comments Mastering PHP Block Comments Jul 18, 2025 am 04:35 AM

PHPblockcommentsareusefulforwritingmulti-lineexplanations,temporarilydisablingcode,andgeneratingdocumentation.Theyshouldnotbenestedorleftunclosed.BlockcommentshelpindocumentingfunctionswithPHPDoc,whichtoolslikePhpStormuseforauto-completionanderrorche

PHP Data Types Explained PHP Data Types Explained Jul 18, 2025 am 04:36 AM

PHP has 8 main data types, which are divided into scalar types (boolean, integer, float, string), compound types (array, object) and special types (resource, null); where null means that the variable has no value. PHP is a weak-type language, and variables will automatically convert types. For example, adding 10 to a string "123" will turn into an integer 133, but strings that do not start with numbers will turn into 0, which can easily cause errors. It is recommended to manually determine or convert the type when processing input or interface data. Check the type of functions such as is_bool(), is_int(), etc.; casting can be used for (type) or settype() functions.

Setting Up a PHP Environment Setting Up a PHP Environment Jul 18, 2025 am 04:36 AM

Install the PHP interpreter and use package management tools such as Ubuntu's apt or macOS Homebrew installation; 2. Use web servers such as Apache or Nginx, Apache automatically loads PHP modules, and Nginx needs to be matched with PHP-FPM; 3. Install database support such as MySQL and other extensions and enables it; 4. Use modern editors such as VSCode, PhpStorm and debugging tools Xdebug to improve development efficiency.

See all articles