Your Best Function

Discussion in 'PHP' started by adamjblakey, May 2, 2007.

  1. #1
    Hi,

    I was wondering the other day, there must be loads of very useful and excellent functions that people have wrote in the best. And would be useful if you would like to share them with everyone and explain why it has been so useful to you.

    Mine personally is a simply function to limit a text output to e.g. 50 charaters. Maybe not the most complex but i use it all the time.

    Cheers,
    Adam
     
    adamjblakey, May 2, 2007 IP
  2. krakjoe

    krakjoe Well-Known Member

    Messages:
    1,795
    Likes Received:
    141
    Best Answers:
    0
    Trophy Points:
    135
    #2
    I wrote a function / functions to turn php into windows exe, that's probably my best yet ...... however, you can't really describe it as non complex, and as you can see from my website I do infact use it all the time, daily, infact hourly on my pc
     
    krakjoe, May 2, 2007 IP
    ErectADirectory likes this.
  3. venetsian

    venetsian Well-Known Member

    Messages:
    1,105
    Likes Received:
    61
    Best Answers:
    0
    Trophy Points:
    168
    #3
    Heh .. my best one was search engine that ranks pages very similar to google. I wrote it in two days .. but that's definately not as complicated as making php to exe .. at least for me it sounds like that ..

    Cheers,

    Venetsian.
     
    venetsian, May 2, 2007 IP
  4. ErectADirectory

    ErectADirectory Guest

    Messages:
    656
    Likes Received:
    65
    Best Answers:
    0
    Trophy Points:
    0
    #4
    KrakJoe's got skills no doubt. I saw that about a month ago when you released it here and wondered why it didn't get the noble prize. Getting PHP to run on windows as an exe!!! are you shittin me!!! little to no publicity??? I'm holding off downloading it until I have an immediate need for it. If not, it will get lost in my system (like I'm organized enough to call it a system). I think I gave you rep then, but either way I'll do it again now.

    I'm working on a publically available function (more like an api) that returns the critical statistics for a web page (site). This will be cool and will help a lot of people out.

    I'm probably proudest of my dynamic PDF work on corporate web sites. Totally commercial intentions for that project, no open source there. I have several business clients that rant and rave about how it has helped streamline their business workflow and given power to their sales force. It can produce camera ready art through a form online. It's more of a stand-alone program that a function but could be easily converted. Check out the Business Card Demo.
     
    ErectADirectory, May 2, 2007 IP
  5. adamjblakey

    adamjblakey Active Member

    Messages:
    1,121
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    80
    #5
    Sounds good guys, and really good Joe. I did not even know that you could do that.

    Also i like the PDF work that ErectaDirectory has done, and will look forward to your statistics work.
     
    adamjblakey, May 3, 2007 IP
  6. Weizheng

    Weizheng Peon

    Messages:
    93
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Impressive tools you have in your site - each of them on their own is a potential link bait. I think you could have made them more download friendly like giving more details, screen shots and maybe some assurance of being virus free.
     
    Weizheng, May 3, 2007 IP
  7. krakjoe

    krakjoe Well-Known Member

    Messages:
    1,795
    Likes Received:
    141
    Best Answers:
    0
    Trophy Points:
    135
    #7
    Thanks, I do my best :)

    The cms that runs the site is very much unfinished, its hard to find the hours spare to work on it, it'll work out in the end, I'm in no rush, it's only been open for a month, also, there is screenshots of them :S if you click on the image you'll get a better view of each script or program, the scripts don't really need screenshots, they are php !!

    It hadn't even crossed my mind to mention viruses, it's not really the sort of word you want on a programming site is it ??
    So what should I have a disclaimer page or something ( might not be the word for it ?? ) ?? any input is appreciated ......
     
    krakjoe, May 3, 2007 IP
  8. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #8
    I would add at least a note that says that the usage of any code from your site can be used freely, at own risk. Not that I think that any of your scripts is going to cause damage, but what if it happens and the user calls his lawyer?

    I'm specially careful with this, because I once used a script from another site, and it deleted the whole database from website of the company I work for, and they (my company) had to pay like $780 to get a backup. :p So by simply adding a note you're definitely out of any problems.

    Also (while we're on the subject, lol), I'd may state under which license these codes are release. Like GPL, etc... So people don't get wrong ideas.
     
    nico_swd, May 3, 2007 IP
  9. KalvinB

    KalvinB Peon

    Messages:
    2,787
    Likes Received:
    78
    Best Answers:
    0
    Trophy Points:
    0
    #9
    You shouldn't run code you don't understand.

    I have apache/php/perl/mysql running on my machine and I run any complex foreign scripts on it before considering putting them into any real projects.

    ----

    I recently wrote a PHP script that reads in Perl files and determines what all the functions are and where they're used. It tells me files and line numbers. It allowed me to quickly get rid of dead code.
     
    KalvinB, May 3, 2007 IP
  10. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #10
    I usually use my own code for almost everything. I just downloaded this because it was a database backup script, and I wasn't too familiar with writing my own, and I didn't want to spend too much time with it. At least I learned from my mistake, lol.
     
    nico_swd, May 3, 2007 IP
    commandos likes this.
  11. Spikeon

    Spikeon Peon

    Messages:
    61
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #11
    wow...
    the best i've written is one that trims out illegal characters, trims out whitespaces, and then gets rid of badwords...

    i feel so pathetic right now...
     
    Spikeon, May 3, 2007 IP
  12. krakjoe

    krakjoe Well-Known Member

    Messages:
    1,795
    Likes Received:
    141
    Best Answers:
    0
    Trophy Points:
    135
    #12
    Are you serious ?

    IMO that's a pretty stupid thing to say, how should people learn if they dont go near things they don't understand ?

    Nico learnt, proving my point, you should be more willing in most cases to try new ideas and new code, instead of sticking to what you know and never getting any better.
     
    krakjoe, May 4, 2007 IP
  13. KalvinB

    KalvinB Peon

    Messages:
    2,787
    Likes Received:
    78
    Best Answers:
    0
    Trophy Points:
    0
    #13
    I said you shouldn't run it. I didn't say you should avoid it. You need to know what code does before you run it or you risk problems.

    If you have no concern for your development environment then go ahead and run whatever code you want without looking over it first.
     
    KalvinB, May 4, 2007 IP
  14. krakjoe

    krakjoe Well-Known Member

    Messages:
    1,795
    Likes Received:
    141
    Best Answers:
    0
    Trophy Points:
    135
    #14
    It's not practical to learn every piece of code that you use, you or I may have the ability to do that, or not have to use code we don't know, but as a general rule it really doesn't stand up, you can only "know" code if you're the programmer or at least a programmer, most people are not, even most people that use php are not programmers they are webmasters.

    If you want to apply a rule to the sort of code you run, then make sure it comes from a reliable source, definately, but not really know the code.
     
    krakjoe, May 4, 2007 IP
  15. ErectADirectory

    ErectADirectory Guest

    Messages:
    656
    Likes Received:
    65
    Best Answers:
    0
    Trophy Points:
    0
    #15
    1. It is not possible to look over every line of every code for a big implementation of a script (eg. a forum, wiki, blog, etc.). Get those programs from a trusted source like SF. If you examine everything you will never get anything accomplished.

    2. Absolutely, you should look over any small function that you intend on implementing inside of a working site. For instance, if I wanted to use Spikeon's function to strip illegal characters from a string I would look over it to make sure all is well.

    There is a big difference from a small function and a working program. It is a good rule of thumb to check anything you add to a functioning site for simple things like "delete * from" & shit like that.

    I think a better idea is to just make AWESOME backups so that you can try whatever code you want to see if you like it, if so just hack it in place later. This is not valid when a site is live though, only in your playground.
     
    ErectADirectory, May 4, 2007 IP
  16. KalvinB

    KalvinB Peon

    Messages:
    2,787
    Likes Received:
    78
    Best Answers:
    0
    Trophy Points:
    0
    #16
    I highly recommend Subversion.

    That's why so many web-sites get hacked. Non-programmers trying to program results in nothing but problems.
     
    KalvinB, May 4, 2007 IP
  17. dp-user-1

    dp-user-1 Well-Known Member

    Messages:
    794
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    110
    #17
    KalvinB, you're telling me you never had to learn PHP? You were just born with it?
     
    dp-user-1, May 4, 2007 IP
  18. KalvinB

    KalvinB Peon

    Messages:
    2,787
    Likes Received:
    78
    Best Answers:
    0
    Trophy Points:
    0
    #18
    Would you want a non-mechanic working on your car?

    Non-programmers are people who have no interest in actually learning how to code. They just install other people's code and pray. Occasionally they hire someone who knows what they're doing.

    Noobs install other people's code and tinker with it to see how it works and try to change it to make it better. Eventually they can write their own code from scratch. They occasionally land jobs working for non-programmers.
     
    KalvinB, May 4, 2007 IP