Jump to content
Larry Ullman's Book Forums

Any Such Thing As An Event In Php?


Guest Deleted
 Share

Recommended Posts

Guest Deleted

You know how there are events in JavaScript? Is there anything comparable to that in PHP? Can a server-side language even have events?

Link to comment
Share on other sites

There are no events, per se, but there are callback functions for things like ob_start, etc.

If you think about it though, events don't mean as much for a server-side language, although server-side languages like Node.js utilize event-like structures for things (since Node.js is intended to function like JS on the server side).

Link to comment
Share on other sites

When I think of events/not-events, I look at whether the thing is constantly running or not. Desktop applications, mobile applications, and web applications (with JavaScript) are constantly running, so they react to events. A PHP script is requested, executes, and then stops. In theory there are event-y things during execution, but the PHP script doesn't continue to run after completion, so it's not watching for or listening for events the way JavaScript is in the web browser. 

Link to comment
Share on other sites

Guest Deleted

Enlightening. Thanks guys.

 

And speaking of Node.js, what is you guy's opinion on that? I hear people saying it's going to replace PHP. Do you guys think it will?

Link to comment
Share on other sites

Guest Deleted

Thanks for the answers guys. It's good to hear that my language of choice should be around for awhile longer :)

 

So, what do you think it is about PHP that has allowed it to remain so popular? Do you consider any of the following to be reasons:

-More friendly to beginning programmers than are many other languages
-Most hosting plans support it
-You have things like XAMPP which let you easily create a web server environment on your computer
-Can easily find books, tutorials, stack overflow questions etc. about almost anything you could want to know
-Lots of other people code in PHP, so there are lots of people to ask questions
-Updated like every year (not sure how to word this but I noticed PHP 5.4 came out one year, next year 5.5, next year 5.6, etc.)
-Has some good frameworks

Link to comment
Share on other sites

 Share

×
×
  • Create New...