इमेजस्ट्रिंग () PHP में एक इनबिल्ट फंक्शन है जो एक स्ट्रिंग को क्षैतिज रूप से खींचने के लिए उपयोग किया जाता है।
सिंटैक्स
bool imagestring($image, $font, $x, $y, $string, $color)
पैरामीटर
इमेजस्ट्रिंग () छह अलग-अलग पैरामीटर स्वीकार करता है - $image, $font, $x, $y, $string, और $color.
-
$छवि − $image पैरामीटर दिए गए आकार में एक ब्लैंक इमेज बनाने के लिए imagecreatetruecolor() फ़ंक्शन का उपयोग करता है।
-
$font - $font पैरामीटर का उपयोग 1, 2, 3, 4, और 5 इनबिल्ट फोंट के लिए फ़ॉन्ट आकार मान सेट करने के लिए किया जाता है।
-
$x - क्षैतिज X-अक्ष, ऊपरी बाएँ कोने में फ़ॉन्ट की स्थिति को बनाए रखता है।
-
$y - फ़ॉन्ट की स्थिति को ऊर्ध्वाधर Y-अक्ष, सबसे ऊपरी कोने में रखता है।
-
$स्ट्रिंग − $string पैरामीटर में लिखी जाने वाली स्ट्रिंग होती है।
-
$रंग - यह पैरामीटर छवि का रंग रखता है।
रिटर्न वैल्यू
इमेजस्ट्रिंग () सफलता पर सही और असफलता पर गलत लौटाता है।
उदाहरण 1
<?php
// Create the size and image by using imagecreate() function.
$img = imagecreate(700, 300);
// Set the background color of the image
$background_color = imagecolorallocate($img, 0, 0, 255);
// Set the text color of the image
$text_color = imagecolorallocate($img, 255, 255, 255);
// Function to create an image that contains the string.
imagestring($img, 50, 180, 150, "Tutorialspoint", $text_color);
imagestring($img, 30, 160, 120, "Simply Easy Learning", $text_color);
header("Content-Type: image/png");
imagepng($img);
imagedestroy($img);
?> आउटपुट

उदाहरण 2
<?php
// Create the size of the image or blank image
$img = imagecreate(700, 300);
// Set the background color of the image
$background_color = imagecolorallocate($img, 122, 122, 122);
// Set the text color of the image
$text_color = imagecolorallocate($img, 255, 255, 0);
// Function to create an image that contains a string.
imagestring($img, 10, 30, 60,"Tutorialspoint:Simply Easy Learning", $text_color);
header("Content-Type: image/png");
imagepng($img);
imagedestroy($img);
?> आउटपुट
