Is there a book on php for socket programming? [closed]
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
开发者_StackOverflow中文版 Improve this questionI already have some experience with Java and a bit with C/C++, I'd like to learn PHP now. I want to make some applications with sockets, which I already understand a bit of. However, it seems most books focus on PHP for web development, whereas I'm more interested in it as a general purpose programming language.
Am I "doing it wrong" or is PHP viable as am I hoping it to be? if it is, are there any good books on the subject?
Having written web spiders and other command-line based scripts before in PHP, I can tell you that PHP is a viable option for a general purpose programming language.
The reason most of the books are web-oriented is because PHP is designed to be a web programming language (its name, after all, is the "PHP Hypertext Preprocessor"). Your best bet for "general purpose" use of the language would be to make heavy use of the PHP Manual, including the comments (there are a lot of good comments that include examples or links to various things that will be helpful).
The PHP manual has a whole section dedicated to command line use, and another section on the use of sockets.
Other than the manual, Google is your friend.
Find a good book on sockets that is geared toward unix C/C++, as there is considerable cross-over between C and PHP.
It won't help you if you want to write a multithreaded server, or a server that even forks for each connection, but to get an understanding of sockets that can apply to php this may be your best bet.
While PHP can be used as a general purpose programming language, it is DESIGNED for use in webpages. It's NOT a good choice for general systems programming use, nor is it particularly suited to any standalone application, particularly one involving sockets.
Instead, learn python. It's different from C or Java. It's a general purpose programming language, has widespread adoption, supports the various system calls you'll be wanting, if you're doing a socket-based application, and has better overall language design.
If you don't believe me, go look at the naming for string functions in php. It grew organically, and it suffers from it.
精彩评论