I'm a newbie to php, don't think I should ask this question because I think people are going to vote it down, so just curious how to limit character output on a field in a loop
when I get a query for field named description, it sometimes has up to 500 characters and I want to limit it to 200 when I echo it like this <?php echo $row['description']; ?>
something along those lines, that way even if font size or font family varies you won't end up with empty space or too little space as the browser truncates the text at the exact spot. Relying on the character count is not always ideal.
Hey guys, I want to ask something. I got a job offer with a decent salary but they want me to add features to their complex/spaghetti PHP codes (an ERP system that around 150 people uses)
well, i am gonna ask a question... which may look like JAVA. but its more of a design pattern thing...
btw Merry Christmas to all
i have been trying to develop a basic image filter app
at first i had a single file and two classes in it... like thus..
`class ImageProcess{
BufferedImage img=null;
BufferedImage(File input){
//initialize the image file;
}
public BufferedImage setContrast(BufferedImage newImg){
//logic for contrast
return newImg;
}
public BufferedImage setBrightness(BufferedImage newImg){
//logic for brightness
return newImg;
}
public BufferedImage makeGrayscale(BufferedImage newImg){
there are very little probability that your issue requires all that code - so sense of your question will be understood by those, who're reading it (well, problems that require long code listings exist in real life, but they are very specific and rare). Thus, you may consider it as a rule - probability of getting right answer becomes lesser when code size grows
but i am much behind in the race, i think.. i perform worst in any kind of competition.. so i do things for myself... :) .. myt be thats why i am slower... well, if u did get my problem, then i was hoping for some solutions , atleast ideas to solve it
the only suggestion for this is - if you don't know which pattern to use, then don't use any pattern. Pattern is something that you must understand - what is it, why is it and when it can be applied
or else - ok, some person will say to you "use pattern ZZZ here". So what? You'll not able to breakdown it and get the sense - why that pattern is good for your case and what that mean. It will be like monkey-style (i.e. repeat without understanding, which will grant no benefits in terms of knowledge). Or may be that person is wrong and that pattern isn't good for the case? You'll never be able to discover that
actually i want to segregate these methods into different class which would reside in different file.. for example: `class Adjustments` would contain `contrast and brightness` would-be saved as `Adjustments.java` . 'class Colors` would contain `saturation and gamma` in `Saturation.java` and like wise and then have access these classes and their functions wherever needed. Now the thing is i cannot be importing all the 6 packages (like imageio, awt.Color) in all the separate java files. So what would be the possible solution to have one single class that will contain all the packages and the…
in C comma operator means sequence point - that is, it's a sequence of expressions that will be evaluated in left-to-right order. Resulting "whole" expression (that is what will be "returned" as a result of round brackets) will be equal to most right expression in sequence (i.e. last expression in sequence)
so - that is 7 in your sample, i.e. your j will be equal to 2+7
to say more, if expressions in list have no side-effect, that makes no sense at all and such list can be replaced with single expression, which comes as it's last element
the only suggestion for this is - if you don't know which pattern to use, then don't use any pattern. Pattern is something that you must understand - what is it, why is it and when it can be applied
@AlmaDo that's just load of BS. Patterns are names for describing code that has already been written.
@tereško I always thought that patterns are concepts.. and certain code just implements that concept. So code is not a pattern, while concept is. Eh.. but that's my imho
@Fabien I have nothing to do.. one of reasons. Also - I'm learning while answering. Some questions are really nice - so that's a challenge also in some sense
heh.. first time I've opened flagging page and, after deeming 40 daily flags - I've realized that they were serial flags.. so bad that there are so many poor answers
> <arun_> Anyone know how to test a post request functionality using phpunit ? Do we need to use any other framework [zend , symfony ] to achieve this functionality ?
Facebook somehow manages to run a large-scale website with PHP by means of custom-written PHP extensions in C and several terra bytes worth of memcache
@tereško I'm willing to bet 10$ he doesn't get 1/4 of it the first time unless he's actually had to face the use cases.
You can't learn design patterns from a book if you've never been in situations where those patterns were applicable yourself before. Otherwise you just don't understand - or worse, it looks like "useless cruft" or "just longer code" or whatever.
It's not that, the problem is examples don't really work, and Fowler doesn't presume.
You'll find no idiotic stupid examples in PoEEE, which is much better than a lot of other books but still - you're expected to know the problem.
That's the thing, I can't explain how important DI is to someone who was never in global state hell or testing hell. I tried, it goes right past students.
When they hear me say it - it goes right through them. It looks like cruft because they don't understand the underlying issue
All I'm saying @Fabien is make sure you understand the problems first
@AlmaDo With large data, it is very important to have a key on the table to improve performance. When working on a development team on a production server it came to my attention that a user's site running our software was going over the PHP run time and not able to render a page. The solution wound up being that they had several thousand posts in the database without a primary key. After added a primary key, the site was lightning fast.
@webarto Awesome. BTW your code stinks and I want to PR shit, but not sure how far I can take it to PR without sending you over an entire rewrite at some point. I will send you over the first rewrite later with cleaned up html and shit.
You want to reduce the impact of the query over all rows running the comparison function to find out if that row matches the span of numbers X lies in or not.
As you have outlined, the effectiveness of some common index is not of much use because of the sheer amount of numbers / row ratio.
This...
I have been wanting to do something with it for such a long time and now I finally have a couple of days off so I can do shit and make it awesome and created a app for it
well they probably write some of it in higher level stuff now I guess ... but there was a time when it was only C[++] and asm, there are no operating systems without a native compiler, how on earth would that even work ...