News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

PHP GD Image Dynamic Signature Help

Started by Scareface, June 06, 2013, 10:22:32 AM

Previous topic - Next topic

Scareface

Hey guys can someone help me with creating dynamic signatures ?

<?php

header
('Content-type: image/png');
$img = imageCreateFromPNG('bg2.png');
$fontcolor = ImageColorAllocate ($img, 0, 0, 0);
ImageString ($img, 5, 40, 11, 'ssi_latestMember()', $fontcolor);
ImagePng ($img);
?>


I want to display some information for example, latest user. So can someone explain me how to get the latest user ?

Will Sabransky

A few issues:


  • Since your parameter 5 is enclosed in single quotes, it will pass the name of the function you're trying to call as a string literal rather than call the function and pass its return value.
  • ssi_latestMember takes a parameter which determines whether it will display or return data. The default behavior is to display data. Try using ssi_latestMember(null).
  • Once you call the function in a way that returns data, the return value will be an array of member information, not a string.

With that in mind, try something like this:


$mem_info = ssi_latestMember(null);
ImageString ($img, 5, 40, 11, $mem_info['name'], $fontcolor);

Scareface

Thank you it works. But few questions, why are we using Null ? and is it same like this for all functions ?

Will Sabransky

If you take a look at the API documentation, you'll see that ssi_latestMember() takes a single parameter that controls output type. If the string 'echo' is passed to the function, it will print the information to the user. If any other value is passed, it will return an array with the info. However, the default value for this parameter is "echo," so if you don't pass any value, it won't return anything. This is why we pass a null parameter instead.

Scareface

Thanks for you help. Created a script :)


Advertisement: