Shrink PHP code
Moderator: General Moderators
Shrink PHP code
Yes, this is weird. I need to shrink some PHP code. Does anyone know a script that does this?
- Ollie Saunders
- DevNet Master
- Posts: 3179
- Joined: Tue May 24, 2005 6:01 pm
- Location: UK
Re: Shrink PHP code
A quick google produced this. Use the verb minify or noun minification to search for other implementations if you wish.
Re: Shrink PHP code
thanks. I can find lot's of tool for js, css and html, but I couldn't find any for PHP.
- Ollie Saunders
- DevNet Master
- Posts: 3179
- Joined: Tue May 24, 2005 6:01 pm
- Location: UK
Re: Shrink PHP code
Why do you need this?
Re: Shrink PHP code
I've made a PHP app for a contest that has a 100KB limit. My app is slight bigger, so I need to make it smaller
Re: Shrink PHP code
Try removing all the tabs and new lines. Comments too.
You could base64 encode it and eval it on execution. That should compress it a bit...
You could base64 encode it and eval it on execution. That should compress it a bit...
- Ollie Saunders
- DevNet Master
- Posts: 3179
- Joined: Tue May 24, 2005 6:01 pm
- Location: UK
Re: Shrink PHP code
You could:
- Refactor; there's probably duplicated code you can remove. The shear number of refactors that are possible virtually guarantee this will be useful unless your code is already very well factored, which almost nobody's is.
- Remove some unnecessary features; at least one is present in nearly every project, sometimes there are many.
- Change to tab indentation if you were using spaces.
- As jackpf suggested, removing unnecessary comments it also good. A lot of people repeat the license in every file for instance.
Re: Shrink PHP code
I have already done what you suggested, but thanks anyway.
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Re: Shrink PHP code
jackpf wrote:Try removing all the tabs and new lines. Comments too.
You could base64 encode it and eval it on execution. That should compress it a bit...
The Manual wrote:Base64-encoded data takes about 33% more space than the original data.
Re: Shrink PHP code
Oh right. My bad.