0

I have an image generating class and a number of sub classes inherited from this. Each sub class generates a different image. I would like to pass the class to generate (or some sort of identifier) in the URL. EG: www.mysite.com/image.php?class=image002 In image.php I could read the class name from the URL, compare this to my database to find the class, then include that class file and generate. I feel that this is not the correct way of doing it. Are there better ways?

jme
  • 311
  • 4
  • 19
  • You don't want to generate classes dynamically. You make one class flexible to generate images dynamically. Not the other way around – HamZa Apr 26 '14 at 09:02
  • I maybe be generating dozens of images so one class is unacceptable. I planned on having a different class per image that would implement a "display" method of some sort and inherit the other methods from the top class – jme Apr 26 '14 at 09:07
  • I thought you were talking about classes as in [php classes](http://www.php.net/manual/en/language.oop5.php) :) – HamZa Apr 26 '14 at 09:09

2 Answers2

0

Apparently there is nothing wrong with your passing values into url that way especially if these image names are unique and are not sensitive data. unique so that you dont execute the same class with two different images. but you could just append/prepend a random string to the image value. also as hamza said hope they aren't php classes

d.bayo
  • 154
  • 4
  • 14
0

I am going to go with this answer:

"Instantiate a class from a variable in PHP?"

instantiate a class from a variable in PHP?

Community
  • 1
  • 1
jme
  • 311
  • 4
  • 19