Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3598036
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T20:11:33+00:00 2026-05-18T20:11:33+00:00

<?php if(isset($_GET[‘img’]) && is_numeric($_GET[‘img’])){ $img = $_GET[‘img’]; $imgarray = array ( ‘1’ => ‘http://www.path/to/image1.png’,

  • 0
<?php
if(isset($_GET['img']) && is_numeric($_GET['img'])){ 
$img = $_GET['img']; 

$imgarray = array ( 
'1' => 'http://www.path/to/image1.png', 
'2' => 'http://www.path/to/image2.png', 
'3' => 'http://www.path/to/image3.png'
);

$src = $imgarray[$img];
header('Content-type: image/png');
echo file_get_contents($src);
}
else
{
    header('Content-type: image/png');
echo 'Image could not be loaded';
}
?>

Hello again stackoverflow!
Im having multiple problems.
1: When the $_GET[‘img’] is set and its numeric, the image will be displayed right, but i want to add text in the upper-right corner of the image… How can i do that? I’ve looked through multiple GD tutorials and examples but i can’t find my answer.
2: When $_GET[‘img’] isn’t set i want to display the text: Image could not be loaded. How cna i do that? Because this doesn’t seem to work…

Greetings

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T20:11:33+00:00Added an answer on May 18, 2026 at 8:11 pm

    What you’ll have to do is use GD. Load up the requested image into PHP with imagecreatefrompng(), since you have listed pngs in your array, you’d have to use imagecreatefromjpeg() or whatever depending on their format. Then use one of the text writers like imagestring() to write the text to the location in the image resource returned by imagecreatefrompng(), then return the image resource to the browser.

    Can also use one of the functions that uses an external font, like imagettftext(), but would need to have the appropriate font to use on the server.

    For the error, if you want it to be an image, you’ll need to use imagecreatetruecolor() to make a new image, then use imagecolorallocate() to assign a color palette to it, then use imagestring() to write the error message to the image and return it. Of course, probably be easier just to make an error image in GIMP or something and return it, rather than going through the trouble of generating a new error image each time.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I got some legacy code that has this: <?PHP if(isset($_GET['pagina'])==homepage) { ?> HtmlCode1 <?php
I have this code <?php session_start(); if (isset($_GET[cmd])) $cmd = $_GET[cmd]; else die(You should
Take this code: <?php if (isset($_POST['action']) && !empty($_POST['action'])) { $action = $_POST['action']; } if
<?php if(isset($_SESSION['cnt'])&&($_SESSION['cnt'] == 5) ){ $_SESSION['cnt'] = 0; ?> <script> //$(#fb_login).trigger('click'); //$('#fb_login').click(); $(#fb_login).click(function(){ $(#fb_login).colorbox({width:300px,
PHP has a very nice function, isset($variableName). It checks if $variableName is already defined
<?php $var = NULL; var_dump(isset($var)); // bool(false) var_dump(isset($unset_var)); // bool(false) ?> isset($var) should return
<?php session_start(); include(connect.php); $timeout = 60 * 30; $fingerprint = md5($_SERVER['REMOTE_ADDR'] . $_SERVER['HTTP_USER_AGENT']); if(isset($_POST['userName']))
PHP's explode function returns an array of strings split on some provided substring. It
i have a site with a simple PHP-Navigation (using $_GET-Variables). HTML-code for navigation links
I'm running PHP 5.2.6 on a Windows Server 2003 Enterprise box. IIS is set

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.