Jump to content


Photo

Big Favour, Checking a class


  • Please log in to reply
2 replies to this topic

#1 onlyican

onlyican
  • Members
  • PipPipPip
  • Advanced Member
  • 921 posts
  • LocationHants - UK

Posted 07 September 2006 - 10:57 PM

Hey all
OPP to OOP
(soz wanted to say that for ages)

Anyway
I was building something to check, resize and upload images

I was doing it, then I thought, I would put each little bit into a function
So theres a function to check the image
There is a function to Get the new image width and height
There is a function to Resize and upload the image

Then I looked at it, and thought I would try and make it a class
THis is my first ever class
So I dont pick up bad habbits and keep doing things wrong, I wanted to ask the brains if they could take 3 mins to check it.
The phps file is here
http://onlyican.com/...upload_img.phps
There is no php uploaded there

I have tested it on my local machine, and it works. It uploads the images I want
Fails on the images I dont want

Any problems u can see or anything, please let me know

I think I have covered every little bit on that code

Tell me the problem, I will try tell you the solution

#2 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 07 September 2006 - 11:20 PM

Just because your code is contined within a class does not mean it is OOP. Your class is fairly static and would be hard to make customizations to without going in and actually changing code.

For instance your $allowed_file_types array should probably be made into a property which could then be set from outside the class, instead of being built into it. Same with wanted height and width, which by the way is a complete misuse of constants.

There is plenty more we could go into, but these things might help you as a starting point.

#3 onlyican

onlyican
  • Members
  • PipPipPip
  • Advanced Member
  • 921 posts
  • LocationHants - UK

Posted 07 September 2006 - 11:33 PM

ok thanks
and the 2 defines was originaly outside the code, which is why they are constants, but I could't work out how to include them into the code
Same as the $allowed_file_types

So I need to make them Properties (and the constants, variables)
Tell me the problem, I will try tell you the solution




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users