Can we convince StackOverflow that if a php questions contains mysql_* in the code to automatically close the question? It would make life so much better!
It's amazing how quickly you forget things once you stop writing code in a certain language. I've been writing mostly Scala for the last two months and I actually spent 5 minutes this morning trying to remember how static variables worked in PHP.
Or it could just be that I'm getting senile. You never know.
Certainly not. I've been using Golang and Rust more and more, sometimes I come back to PHP trying to define type information with function($var string), the other day I was in doubt if I should use static:: or self:: and was surprised __CLASS__:: is a syntax error.
I found haskell too dificult to read :x but maybe I didn't persisted enough to become "fluent" in it.
The biggest problem with Rust to me is that they can't decided how to design their things and keep it as it is. Even after 1.0. But hopefully it will stabilize more in the future. The compilation time is unbearable once you start to add larger deps to your project.
@marcio well… then compile it first and start integrating (aka coding) the dep while you're compiling in background?
@marcio but, uh well… that's part of why you install things in shared libs (you pull from a distro or such) in order to avoid recompiling everything on a fresh machine.
@bwoebi I started with Rust not too long ago, my steps between code > debug are quite small compared to Go, for example. But they promised compilation time will be much smaller soon.
@bwoebi You don't need to. function foo($obj) { $obj->prop = "change"; } $obj = new Obj; $obj->prop = "not changed"; foo($obj); // $obj is mutated without references!
@bwoebi Because a reference is tied to a zval, which is just another form of indirection. But one the user doesn't really know about or have direct control over. So references are more confusing. They're tied to the variable that created them.
An object, at least, is stored in an object store. The variable is moot.
@bwoebi Easy, you use them for all the wrong reasons. For example, some people thing it's a good way to optimize memory usage. But if you break the is_ref you could end up increasing memory.
@bwoebi The confusion isn't the variable scoping. It's that arrays themselves also carry another level of indirection. So it's actually possible to send an array that contains references to other variables to the function, which might alter them, and they wouldn't expect the global variables to be altered.
@bwoebi True enough, but my point still stands. Objects are better for all the problems that references were meant to solve without any of the confusion.
I've seen noobs wrap their heads around objects more quickly than references.
In PHP, anyway.
References are just obscured by the fact that they deal directly with variables, which in PHP are very unobvious. For example, in PHP $a = 1; $b = $a; // you don't understand the distinction that $a and $b both carry the same value until someone tells you
@bwoebi Actually, I find that the ones struggling the most with these issues aren't the ones coming from other languages. When you explain to someone coming from C or C++ that references aren't pointers in PHP they usually get it right away. But when you try explaining that to someone that has no preconceived notion of indirection in programming, they wrestle with it quite a bit.
If we just remove references from the language the vast majority of people will not suffer, because there are better ways of doing everything that a reference does in PHP without the added subtle side effects.
Of course, this is just my opinion. Obviously, some people out there will object.
"Look, I attempted to solve a problem that takes the average programmer thousands of lines of code to solve well, in a single line of code, and for some very strange and inexplicable reason--it didn't work :("
@NandanPriyadarshi Don't ask to ask if asking about the thing you want to ask about is worth asking about to the person that is willing to ask what you want to ask about. Just ask! If someone knows they'll answer.
@Rahul2001 Completely and utterly irrelevant information. Try providing the error message you got rather than arguing over moot, subjective, tid bits of suggestions that have probably have nothing to do with solving you problem.
Imagine that. Reading the error message results in solving the problem and avoiding a useless argument on the Internet about "the right way" to do something.
@Rahul2001 anyway, $_REQUEST is the sum of _GET, _POST and _COOKIE. it is basically a very effective way to make an incomprehensible mess and should be avoided
@Wes Correction: $_REQUEST is the union all of variables_order. There may be cases when you want$_REQUEST. Don't make blanket statements of right from wrong. Instead, teach people what something does and let them make their own decisions about what is right for them.
Trying to teach people right and wrong in programming is like trying to teach people what is impossible. If we did that we'd never make any strides in technology. Instead, teach people what is possible and let them figure out what they can do with it.
Telling someone that they should never use $_REQUESTbecause FUD is useless information that only serves to scare people away from understand what $_REQUEST is or how it could be useful to them. But explaining to people exactly what $_REQUEST is and how to control it's behavior (i.e. request_order), on the other hand, allows you to make a sensible decision about its usefulness.
completely disagree with that. "just don't do that for now" and "you'll eventually figure out why" works for novices. the reason hardly can be understood by a beginner, and frankly if i was a beginner i would be scared to hear it
@Wes Right, and it only took me one sentence to explain all those risks to you. I can definitely see how a beginner could hardly understand that.
Sometimes our reasoning for defending a bad idea is based on our own lack of understanding.
The better outcome is to always educate rather than say "because FUD"
Beginners often don't have the understanding problem. We do. Because we're filled with years of failure. It's in our bones to tell people NO because where we only remember pain, trouble, and crisis, they have no such memories. They don't yet know right from wrong. They can't tell the difference because they don't know anything yet.
All they know is what you tell them and if what you tell them is to fill their head with fear, then they will never bother to learn.
That fear only stands to grow inside them. It will become more difficult to replace it with knowledge.
i don't think so. i've been taught to do certain things but eventually i wanted to know what i was doing and i started questioning anything. it just takes time. on the opposite, having to worry about REQUEST would have scared me, while being a beginner
i don't think people being told what to do lose the ability or will to learn
It can. When you're constantly told not to do something, because it's bad you have less and less reason to try and understand why or how it's bad. That's not really going to encourage you to want to figure it out later.
You forget that fear is based on a lack of knowledge and to a beginner, they are lacking in all knowledge. So what they have to be afraid of is equally distributed to everything they're learning.
The difference between just don't do this because it's bad and this is what this does is that one ingrains the fear permanently as they knowledge faucet has now been cut-off permanently. The other just turns down the pressure a little.
You can't prevent confusion. You can only try to manage it.
It can. When you're constantly told not to do something, because it's bad you have less and less reason to try and understand why or how it's bad. > i don't think it's like that. maybe it's just me
@Linus If the responsibility of the student is to ask questions. Then it is the responsibility of the teacher to foster curiosity in the student.
Which one fosters more curiosity?
Put it this way: which one is more inviting to open up a dialogue? The approach that reminds the student they are not knowledgeable and that they should accept the dogmatic information you provide? Or the approach that reminds them we weren't born knowing everything and these things can all be learned slowly.
In order to keep learning you must be stimulated to continue asking questions. You aren't likely to continue asking questions about the thing that everyone hates and reams you out for.
@Linus Not everyone is naturally curios. But in a class-room setting it is definitely the teacher's responsibility to create a petri dish for inciting questions from their students.
@Linus It's the Socratic method!
Without critical thinking all knowledge becomes useless.
communication in here is most of times limited to few messages. mine wasn't a "listen to me, i know what i'm doing, then just do this" as i'm a complete nobody on the internet, but more like an invite to question what he was doing if he's interested in doing so
@Wes Except that it didn't pose a question. It made a definitive blanket statement. The intention may be good, but long-term that type of messaging typically just results in even more disastrous outcomes. Not trying to point the finger at you, by the way. I'm just making a general observation that should be taken with a grain of salt.
Yea, but the message doesn't say "this is potentially wrong". It says "this is wrong". I get that your intentions are good. But I would rather start off with a question than a statement. "Why are you using $_REQUEST?" Perhaps they know ... and perhaps they don't. But at the very least the discussion moves from being confrontational to being educational.
Otherwise, it's a waste of time to even make that statement. For all we know they know $_REQUEST is perfectly OK for that use case.
But since we never bothered to discuss the use case and moved directly to "you're wrong" it becomes confrontational.
@Wes Why do you think that? I just provided one such use case.
I think most people just don't know what $_REQUESTis in the first place, because just like you, they were once told don't use it and they never bothered to figure out why.
You have complete control over $_REQUEST. It's 100% under your control. It's well-defined. It's just another super global. So it makes no sense to say that super global X is wrong and super global Y is right.
i won't have myself or anyone else be in the situation to have to decide or be forced to figure out if they should use $_REQUEST or one of the other sg's
i won't have myself or anyone else be in the situation to have to decide or be forced to figure out if they should use $_REQUEST or one of the other sg's
Does any of that sound like someone that values their time and wishes to use it wisely?
Your thesis statement here was that thinking is bad ... yet what you've demonstrated is that a lack of thinking isn't very good :)
reminder to self: when enter room warn everybody that i just woke up and can't even feel my face yet so they won't think i'm elegantly evading discussions
@Wes I have no idea what rhetorical point you're trying to make here. $_REQUEST is not ambiguous. It is well-defined by request_order.
Again, the intent of $_REQUEST is that you don't care where it came from.
Also, you're really bad at making rhetorical points. I wouldn't use that as a tool if I were you. You took the very definition of redundancy and tried to use it as an example of something that's less redundant. Way to go! :D
@Sherif except request_order is customizable in php.ini. how many times did you not care of where the data came from? it's the same that happens with people defending static methods. of course you can use them so that code will be fully testable, so that everything will look and behave perfectly, yet no one is able to tell why i should use them rather than just using regular methods, which can serve the same purpose without being (even if just slightly) ambiguous or redundant
@Wes Not many, but that's not the same as never. Also static methods are yet another bad example, because you're defending the wrong thing there.
What you're saying is a biproduct of a lack of understanding. That's not a defence for I shouldn't use it. It's one for I still don't know how to use it.
Those are two very different arguments.
I use a static method because I don't need access to the object instance.
@Wes I never claimed to defend that point. That wasn't my point. It was yours. The only thing I claimed was knowing what it's for. Not saying whether it was good or bad, right or wrong,.
There is existence is explainable. When you have input variables that can come from either the HTTP body or the query string, and you don't care which one it comes from, all you care about is the variable's value, then $_REQUEST becomes useful.
It's existence explains how it can be useful...
But if you ignore the very thing that makes that possible, then I agree ... will never understand how it's useful.
The fact that you personally haven't found a use for it is irrelevant to that.
Knowing what something does usually suffices to explain where it can be useful and where it is not. Not knowing what something does, on the other hand, only serves to further your confusion. Because you're then only making assumptions about what it does, which can only lead to assumptions about whether or not you need it.
How will that ever result in an understanding of it's usefulness? I posit never since here you are clearly demonstrating a lack of understanding in the thing you claim isn't useful.
You can't claim something is or isn't useful without first understanding what it does. Because without that you don't have enough information to arrive that conclusion.
And informing them what it is and how it works clears up all of that confusion and ambiguity. One's code need not be conforming with everyone else's code unless everyone else plans on working with the same code.
The point here is that you suffer from the very lack of understanding that you detest in others.
I know, because I used to suffer from it too.
Once I tell someone about request_order all of the confusion usually dissipates and they can immediately tell whether or not they actually wanted $_REQUEST or one of the other GPC variables for their use case. Most of the time they don't, but every now and then it actually turns out they do.
The difference, you begin by assuming you know everything there is to know about the problem and work your way up to the solution. That's a hard way to solve a problem. Because a single faulty assumption results in the sum and total of your work being for nothing. The easier approach is to begin by assuming you don't know anything about the problem and work your way from the top-down, learning as you go.
Any single mistake then stands out like a sore thumb, and correcting it is trivial. You need only go one step back to continue progressing.
this script is work in localhost my port no was 25 but when i used this script in server i have foolowing error Warning: fsockopen(): unable to connect to gmail-smtp-in.l.google.com:587 i have searched thru net someone suggest me to change port no
Warning: fsockopen(): unable to connect to gmail-smtp-in.l.google.com:587 (Connection timed out) in /home/manishm2/public_html/screening/recruiter/file_upload/mail/smtp_validateEmail.class.php on line 155 it is the actual message
Great, so at least we know it's a timeout problem. Which means that neither party sent anything down this pipe for the duration of the timeout setting.
ummm, if the server isn't listening on that port that wouldn't help. Your issue is most likely that your server doesn't have those ports open.
@Sherif i would never engage myself into arguments i don't have a complete understanding of them nor i would force my thought to other people. so this ends here
@babi Yes, I got that part already. You ran it on your own computer where you have control over which ports are open. Now you're running it on someone else's computer where you don't. Go ask your webhost to open up ports 25 and 587 for you.
I am working with my local host i connect the live server database.. i connects but took much time near 0.247 + for an connection.. how can i resolve it
Q: kopy.io/S86hA I get this response, the only thing I can be 100% sure of is that "photo index" always starts with 1, I also only have to grab the first one ( so the one with photo index 1). Is there a way to find that one fast?
Hello i have checked port no 25 is open in web server by ip address using tool. I have check status of port no using this site yougetsignal.com/tools/open-ports
@Sherif sorry i dont think it was Internet problem, load on my live server connection Time - 0.0048551559448242, and same time i run my local host connection Time - 0.95328593254089
@dinesh You're trying to connect to a database that is likely thousands of miles away. Your live server is connecting to a database that is likely 10 centimeters away. Which do you think will take more time?
@dinesh Let's put it this way: speed isn't your problem. The speed is beyond your immeidate control. The problem is in time, which has to do with distance over speed. time traveled = distance to travel / rate of travel. So the only thing you can do to reduce time spent making a connection here is to reduce the distance that you need to travel. Why are you connecting to a database over the Internet from your local environment and not a database in your local environment?
Yes database was present in my local host even though i tried to connect my live server and need to work with that, If i live my site with different Servers means files all to be present in a server and database will be in another server, so that only i tried this @Sherif
@dinesh Well, what you're doing is the equivalent of making a trip to the supermarket every single time you need a glass of water. I don't think you will be happy with the amount of time spent making trips to the supermarket after a while.