Extending and Embedding PHP 128
Sebastian Bergmann writes "PHP is a widely-used general-purpose scripting language that is especially suited for Web development. The interpreter that executes programs written in the PHP programming
language has been designed from the ground up to be easily embeddable (for instance into the
Apache Web Server) and extendable. This extensibility is one
of the reasons why PHP became the favourite "glue" of the Web: functionality from existing third-party
libraries (database clients or image manipulation toolkits, for instance) can be made available through
PHP with the ease of use you expect from a scripting language." Read the rest of Sebastian's review.
Extending and Embedding PHP | |
author | Sara Golemon |
pages | 448 |
publisher | SAMS |
rating | 9 |
reviewer | Sebastian Bergmann |
ISBN | 067232704X |
summary | The new standard work on extending and embedding PHP. |
"Extending and Embedding PHP" by Sara Golemon, a long-time contributor to the PHP project, remedies the fact that the internals of PHP are far from being as well documented as the rest of PHP. It brings writing extensions for PHP "to the masses", so to speak.
After a short introduction that makes the reader familiar with terms like PHP Extension, Zend Extension, Userland, and Internals that are used throughout the book, Chapter 1 ("The PHP Life Cycle") opens with an overview of how the PHP Interpreter works and what parts (TSRM, Zend Engine, SAPI, "PHP") it comprises.
Chapter 2 ("Variables from the Inside Out") shows how PHP handles and stores variables internally. The reader learns how to distinguish types, set and retrieve values, as well as how to work with symbol tables. It is in this chapter that the fundamental unit of data storage in PHP, the so-called zval (short for Zend Value) is discussed.
Chapter 3 ("Memory Management") builds upon the previous chapter and discusses more advanced operations on zvals, for instance creating and dealing with copies of a zval or the destruction of a zval when it is no longer needed. To this extent, the Zend Memory Manager is discussed as well as underlying principles such as Reference Counting and Copy-on-Write, for instance.
Chapter 4 ("Setting Up a Build Environment") guides the reader through setting up an environment, either on *NIX or on Microsoft Windows, for the development and debugging of PHP and PHP extensions.
After these first four chapters, the reader is ready to go about writing his or her first PHP extension. Chapter 5 ("Your First Extension") takes the reader through the steps necessary to write and build a simple working PHP extension. The following chapters build upon the knowledge gained here, so that the reader can ultimately implement or change any type of PHP feature.
Chapter 6 ("Returning Values") explains how to pass values (by value, by reference, and through their parameter stack using references) from internal (C-level) functions or methods to userland (PHP-level).
Chapter 7 ("Accepting Parameters") deals with the mechanisms involved in accepting parameters from userland calls to an internal function or method. This includes the discussion of the zend_parse_parameters() API which makes the parameters that are passed to the internal function or method as indirect zval references usable in your C-code. The handling of optional and arbitrary numbers of parameters is explained as well as the usage of type hinting and its arg_info API.
Chapter 8 ("Working with Arrays and Hash Tables") explains the Zend Engine's HashTable API, which is used to store any piece of data of any size, in detail. Its different data storage mechanisms supported are introduced and compared. To quote from the book, "A HashTable is a specialized form of a doubly linked list that adds the speed and efficiency of vectors in the form of lookup indices". Since these structures are used heavily throughout the Zend Engine and PHP and its extensions, a good understanding of this API is vital for any aspiring PHP extension developer.
Chapter 9 ("The Resource Data Type") introduces the reader to the first complex data type (excluding the Array data type that was discussed in the previous chapter, which is just a collection containing primitive data types like strings or numbers). A resource can be, for instance, a connection to a database. It allows the PHP extension developer to "connect abstract concepts like opaque pointers from third-party libraries to the easy-to-use userspace scripting language that makes PHP so powerful".
Chapters 10 ("PHP 4 Objects") and Chapter 11 ("PHP 5 Objects") delve into the last data type supported by the Zend Engine: objects. Sara Golemon dedicates one chapter each to the respective APIs of PHP 4 and PHP 5 because of the huge advancements that were introduced in PHP 5 and that totally changed the APIs.
After the previous chapter, all data types supported by the Zend Engine have been discussed and the book revisits a topic discussed earlier in the book: that of the PHP Interpreter's life cycle. Chapter 12 ("Startup, Shutdown, and a Few Places in Between") explains how to add state to a PHP extension by using thread-safe globals. Along the way, concepts such as internal and external (super) globals as well as thread safety are discussed.
Chapter 13 ("INI Settings") shows how a PHP extension can be made ready for runtime configuration through php.ini settings.
The next three chapters ("Accessing Streams", "Implementing Streams", and "Diverting the Stream") make the reader familiar with yet another important API of PHP: the Streams API. All file input/output in PHP userspace is processed through PHP's Streams Layer. This layer, that was introduced in PHP 4.3, is what makes working with files, compressed files, and remote files, for instance, seamlessly in PHP. The reader learns how to work with streams as well as how to expose streamable resources, whether remote network input/output or local data sources, using the Streams API, thus avoiding the need to reimplement all the tedious bits and pieces that are normally associated with this.
Chapter 17 ("Configuration and Linking") builds upon the tools and techniques introduced in Chapter 4 and adds the GNU autotools (autoconf, automake, and friends) to the reader's set of tools. These tools, if used correctly, allow the extension to be built in environments that the extension author does not know or has no access to.
Chapter 18 ("Extension Generators") takes a look at ext_skel (which comes with the source distribution of PHP) and PECL_Gen (which can be obtained, as the name suggests, from PECL, the PHP Extension Community Library). These two tools automate most of the steps described in the previous chapter and take a lot of tedious work out of the extension writer's hands.
Starting with simple embedding examples, the reader learns in Chapter 19 ("Setting Up a Host Environment") and Chapter 20 ("Advanced Embedding") how the PHP Interpreter can be embedded into almost any other application.
The book concludes with the "Zend API Reference", "PHP API Reference", "Extending and Embedding Cookbook", and "Additional Resources" appendixes. The first two are a great resource for both novice and experienced PHP extension writers (even for people working on PHP and the Zend Engine itself). The third features a collection of common use code snippets while the last one points the reader into the direction of PECL by suggesting a couple of existing extensions to look at and learn from.
Since the topic of this book is to extend the PHP Interpreter using extensions written in the C programming language (or to embed it into an application that is written in C), a good understanding of C syntax, its datatypes, and pointer management is important to get the most out of this book.
Being a contributor to the PHP project for about six years now, I have been looking forward to this book. True, there is always the source code of the PHP Interpreter as a source of information on how "things work". But although being the ultimate reference, reading the source code cannot replace a thoughtfully structured and well written guide that gets you started. If you are looking for such a guide, look no further: you will find it in this excellent book.
Although it deals with a very technical topic, "Extending and Embedding PHP" is readable and the many code examples are easy to follow. The reader profits from the knowledge of the author, who has been involved in the PHP project as a core developer for over four years now and is also the author and maintainer of a dozen PHP extensions that are available through PECL. The book covers both major versions of PHP that are currently used, PHP 4 and PHP 5, and it will continue to serve its purpose when PHP 6 comes out next year.
Sebastian Bergmann spends his free time with the development of Free Software, is a member of the PHP and Gentoo Linux development teams and author of a variety of PHP software projects such as PHPUnit."
You can purchase Extending and Embedding PHP from bn.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.
php-embed (Score:5, Informative)
The reason? PHP is easy to use, loosely-typed (which happened to be an advantage in this case), fast, and of course the license works. It was a great decision.
PHP-embed is basically just a TSRMLS function wrapper. It's pretty straightforward; for example, zval integration is easy as pie, as I recall, something like:
Re:php-embed (Score:2)
Re:php-embed (Score:2)
Re:php-embed (Score:2)
You bastard. You said the evil word and now I can't sleep for 7 days and 7 nights.
Aaaah.... it brings back fond memories of weeks-long being swamped by specs, hundreds upon hundreds of pages of specs. And when you thought you 'got it', some idiot brought out a new document with rather creative new uses of that same spec. I love this HL7 v2/v3 standard shit!
Re:HOW DO I SHOT WEB \(_o)/ (Score:1)
Mod parent up (Score:1)
You CATS with mod points, its you!
You GET SIGNAL!
Your BASE p0wn3d by mod_php!
"Extending and Embedding PHP" (Score:2, Funny)
Microsoft involved here?
Re:"Extending and Embedding PHP" (Score:2)
Other People's Code (Score:3, Insightful)
Agreed, especially when the source code you're reading isn't your own. I claim that 99% of programmers who are not me write totally obfuscated code. Damn them!
Re:Other People's Code (Score:1)
Re:Other People's Code (Score:2)
for( ;
Re:Other People's Code (Score:1)
Sara Golemon (Score:2, Interesting)
Re:Sara Golemon (Score:3, Interesting)
Re:Sara Golemon (Score:1)
5 of first 7 comments trolling (Score:2, Interesting)
I've used PHP for some very small applications/sites. Can anyone give an unbiased (almost impossible I know) state of affairs for PHP? I know that it is a pretty common tool, has its strengths and weaknesses. However, is it really that bad or is bashing it just the current
Re:5 of first 7 comments trolling (Score:1)
Re:5 of first 7 comments trolling (Score:4, Insightful)
I think PHP has replaced Java as the favorite "kick the dog" language on Slashdot. IMHO, PHP is no different than any other language. It takes work to write consistently clear code that other people can understand.
Re:5 of first 7 comments trolling (Score:2)
You can't have a "humble opinion" about a statement of fact.
I work with PHP on a professional basis every day, and I will tell you that PHP has many shortcomings [google.com] that simply are not present in other languages.
Re:5 of first 7 comments trolling (Score:2)
Re:5 of first 7 comments trolling (Score:4, Insightful)
I couldn't have said it better myself. I personally use PHP for many small applications. I also make sure to heavily comment my code, and I try not to obfuscate my code (it kills me that some people compete to see who can write the most obfuscated Perl, for example. Try interpreting or revising that code a year from now).
Many times I've had to revisit code years after having written it, and when there are no comments, it is difficult to see what exactly I was thinking at the time -- in *any* language. Non-descriptive variable names, or attempting to put as much code in as few lines possible, are, IMHO, bad practices.
Personally I see nothing inherently wrong with PHP. If I'm working with a web-based application, under Apache, using a MySQL database, PHP is the first thing that comes to mind. Image manipulation (now integrated) and HTTP features (headers, cookies, form data, file uploads, etc) make PHP an easy choice for many web applications. I've done all of this in Perl, and some in plain-old-C, but PHP makes these things so easy...
Of course it's not for everything. I try to use whatever platform/language is most appropriate for the application at hand. Sometimes it's C or C++, perhaps it's Perl, whatever - I use whatever makes the most sense for what I'm hoping to accomplish. It just happens that, on my Linux server, PHP often stands out as the best choice. When writing Windows applications, I use a hybrid of VB6 and (in the form of a back-end DLL library) C/C++. On the server, PHP most often comes out as the clear choice. Ease of use, abundance of built-in functions/features, ease of database-to-web integration, and relative security all make PHP a good choice for many of my projects and ideas.
Some have referred to PHP as "loose", and I admit sometimes it can be. There is no equivalent to Perl's "use strict", and it's easy to unintentionally leave an opportunity for a user to pass unexpected variables -- but as long as you are able to keep this in mind, it's not difficult to make a relatively secure PHP script. Just make sure any important variables are declared/set/validated at the start of the script. I admit, I do love Perl's "strict" module, since it leaves no question as to whether a variable's data is trustworthy... but PHP is a different language, with different features. You can't discount it as a viable language because of a single missing feature...
Re:5 of first 7 comments trolling (Score:2)
Err... error_reporting(E_ALL|E_STRICT); is what you're looking for. It warns on uninitialised
Re:5 of first 7 comments trolling (Score:2)
I think that was Pratchett.
Re:5 of first 7 comments trolling (Score:2)
Re:5 of first 7 comments trolling (Score:2)
The problem (The reason it's got a reputation for bad security) is that many users don't know about these problems, so they don't write secure code. Stuff like:
$user=$_GET["u"];
$res=mysql_query("select data from users where userid=$user;");
(It's a SQL injection waiting to happen, what if I load this page with u="0;drop table users;"?)
The rapid uptake of PHP among new programmers is
Re:5 of first 7 comments trolling (Score:3, Informative)
Well, one would hope that the READ access you've given to the user you're connecting to the SQL DB with doesn't have the ability to run DROP TABLE.
It's about access control too.
I mean I agree with you on the fact that SQL injection attacks are easier in PHP, but lets face it, you can also design any language to be vunerable. PHP just makes it a little easier by not requiring some sort of connection lib
Re:5 of first 7 comments trolling (Score:2, Insightful)
Re:5 of first 7 comments trolling (Score:2)
Okay, try this:
$result = mysql_query("select password from users where UID = '$uid'");
Assume $uid was passed from a web form. And suppose you passed this to the script:
&uid=0'%20or%20'uid!=0
So, once parsed by PHP, you have:
Just a simple example, but I have seen more complex queries manipulated in a similar manner if the user input isn't properly escaped/valid
Not to be offtopic... (Score:2)
But things like SQL Injection is one of many reasons I just love ASP.NET.
I wrote a very short piece [kjonigsen.net] on this on my site, and how use of paramertized queries/stored procedures in 99% of the cases eliminate this problem entirely.
It also includes a comprehensive SQL Injection demonstration, which I'd recommend that everyone working with DBs should read. Using PHP/Perl/ASP.NET or whatever their favorite web-programming lanaguge happen to be.
Re:Not to be offtopic... (Score:2)
I noticed that the server in question is actually a Windows box running MS SQL. Not that this means anything by itself, but personally I consider Windows to be a desktop OS, and personally I would never rely on Windows in a server environment. But opinions aside...
I admit, the code you exploited could have just as easily been PHP on a *nix platform, so I cannot blame the operating system. I can only blame the programmer that left this
Re:Not to be offtopic... (Score:2)
and personally I would never rely on Windows in a server environment. But opinions aside...
I wouldn't consider any server more secure then the admin actually running the machine. A competent windows admin will more than likely have a more secure setup than a incompetent Linux admin. But, as you said, OS-related stuff aside.
I admit, the code you exploited could have just as easily been PHP on a *nix platform, so I cannot blame the operating system. I can only blame the programmer that left this gapi
Re:5 of first 7 comments trolling (Score:4, Informative)
[sorry for the poor formatting,
function quote_smart($value)
{
if (get_magic_quotes_gpc()) {
$value = stripslashes($value);
}
if (!is_numeric($value)) {
$value = "'" . mysql_escape_string($value) . "'";
}
return $value;
}
Now you call this through sprintf like:
$res=mysql_query(sprintf("select data from users where userid=%s", quote_smart($_GET['u']));
Now this is perfectly safe from SQL injection. Anyone who has done real web programming knows all about this and knows that you need to deal with this sort of thing regardless of what language you're using.
Also, whenever you emit data that will appear in HTML you also need to wrap it. This time you just use the builtin htmlentities() function like:
echo "<input name=\"u\" type=\"text\" value=\"" . htmlentities($user) . "\">\n";
This prevents cross site scripting. Again, no different from any other language.
PS: IMHO if someone goes out of their way to claim something "sucks" they probably don't know what they're talking about. Try the other languages and read the documentation so that you can evaluate which is best for your project.
Re:5 of first 7 comments trolling (Score:1, Troll)
you're inadvertently pointing out more php failures.
When PHP was built, as a set of perl scripts, perl used DBI for databse stuff. And it worked. I don't understand why php fucked it up and then created all the above problems to deal with it.
Re:5 of first 7 comments trolling (Score:1)
"Now this is perfectly safe from SQL injection. Anyone who has done real web programming knows all about this and knows that you need to deal with this sort of thing regardless of what language you're using."
Point taken, in that a lot of web scripting languages you have to be careful with SQL injection - but careful with your statement, I do 'real web programming' and do not have to worry about this per say, as I am using a full MVC framework (struts). If you are truely seperating the 'V' from the 'M' a
Re:5 of first 7 comments trolling (Score:2)
RoR is looking more and more attractive. I'm currently considering porting the next version of the application for which I made my own framework.
Re:5 of first 7 comments trolling (Score:2)
I'm not negating your point, as I do agree with it. But it can be put much more simply: a script should NEVER trust ANY user input, period. Anything passed to the script should be validated; make sure a value is within range, or otherwise is an expected input. If the input doesn't match some predefined pattern, it should be rejected.
I do love PHP, and I use it quite frequently, but Perl has the "scrict" module that I personall
Re:5 of first 7 comments trolling (Score:1)
It's documented in the perlsec perldoc if I remember correctly.
perldoc perlsec
Re:5 of first 7 comments trolling (Score:2)
You're absolutely right -- I confused the two because I used to use both, and it's been about three years since I've done any serious Perl coding. Taint mode (all external data is considered "tainted") helped to ensure that you at least looked at/modified outside data, before you used it. Otherwise, an error was raised.
Strict would have been (if I remember) the module that required you to declare all variables/functions/references. Again,
Re:5 of first 7 comments trolling (Score:3, Insightful)
MOD PARENT UP (Score:2)
Re:5 of first 7 comments trolling (Score:2)
Oops! mysql_escape_string is useless! You need mysql_real_escape_string()!
You just made a textbook example of why PHP is a bad language for web apps. This problem does not exist in decent languages, such as Perl, Python or Ruby.
Re:5 of first 7 comments trolling (Score:2)
Also, regarding sprintf, if your query has 5 parameters using sprintf is a lot easier and it's probably more efficient.
Re:5 of first 7 comments trolling (Score:2)
Also, semicolons aren't needed at the end of MySQL queries in PHP. But that's nothing to do with the code's presentation!
Glad you didn't mention cross-site scripting (Score:2)
register_globals? (Score:2)
rethinking (Score:2)
Re:5 of first 7 comments trolling (Score:2)
$res=mysql_query("select data from users where userid=$user;");
(It's a SQL injection waiting to happen, what if I load this page with u="0;drop table users;"?)
Err.. nothing. mysql_query() doesn't parse semicolons as statement separators. Not to say that there aren't other potential problems with this code, but that ain't one of them.
Re:5 of first 7 comments trolling (Score:2, Interesting)
I believe PHP has a bad reputation for three reasons:
They are gradually fixing the language
Re:5 of first 7 comments trolling (Score:2)
Granted, I've worked with PHP and therefore I don't like it. But that was 4 years ago or so. Maybe things have changed. But I do think parent poster has multiple points, and simply mod'ing him Flamebait since PHP is your favorite scripting language won't change that.
Saying that beginners PHP-code is ugly is more a statement of facts than an opinion.
Re:5 of first 7 comments trolling (Score:3, Insightful)
Re:5 of first 7 comments trolling (Score:1, Troll)
PS. PHP sucks donkey balls.
Re:5 of first 7 comments trolling (Score:1, Insightful)
It's pretty bad. To begin with there's therandom() naming_scheme(). On top of that there's the lack of namespace support, so we have str_pad and strlen rather than something like:
The devs should add namespaces and camelCase all function names (Currently function names are case insensitive). They could even have a secondary function table with aliases for backwards compatability, since simple sed commands or search and replace are apparently too esoteric for th
I second (Score:2)
Re:5 of first 7 comments trolling (Score:1)
Personally I've been programming in both the *nix and Win* environment for 10 years. I find PHP a fast, fun, language that allows me to build solid (mostly web) apps quickly. The language constructs "jus
Re:5 of first 7 comments trolling (Score:2)
My reasons for not liking PHP:
This might be more of a preference than a language feature, but it does allow me to easier spot fuck-ups compile-time, instead of run-time.
While this can be benefitial at times, it is my opinion that most uses of this results in messy code. In the very same was as in classic ASP w/VBscript.
I'm sure I could come up with a thousand reasons, but these are my main 2 grudges with PHP.
Re:5 of first 7 comments trolling (Score:2)
Apart from a google search for "PHP sucks", here's a few I have bookmarked:
Re:5 of first 7 comments trolling (Score:2)
About 7
Re:5 of first 7 comments trolling (Score:2)
Are there quirks? Certainly. I've had a couple functions
Ruby zealots are envious (Score:2, Insightful)
That's because there are people who are trying to reinvent a 40+ years old language who do not like the way PHP has taken over the web. They simply hate the way sites with page names ending in ".php" outnumber sites with pages names ending in ".rb".
Those people are too stupid to understand Lisp, too ignorant to know the good points of Lisp, and too close-minded to try learning how to use Lisp, therefore they tried to create a
Try Ruby (Score:2)
This is a poor excuse for a stab at Ruby. Most Rubyist sites tend to be powered by RoR, which in part explains why you haven't seen many ".rb" pages around. Also, how would Rubyists complain about PHP "taking over" the web (implying this should be the "domain" [pun] of Ruby powered sites) when so few of them were introduced to Ruby before 2000? Though PHP and Ruby were introduced around the same time, it took Ruby slightly longer to reach an English-speaki
Re:5 of first 7 comments trolling (Score:2)
if it can help speed a project along, then it's a good tool. for that project,
if it's stregth's fit with your needs, then it's a good choice.
it it's weaknesses aren't neceassrily a problem, then it's a good choice.
you wouldn't write a kernel in java or python, and likewise you wouldn't write a log file parser in C. there's a reason why millions of web sites out there are based on LAMP. and it isn't because they're "free". a good programmer wr
Baroque doesn't begin to describe it (Score:2)
For example, PHP has a special function to see if a given key is in an array:
In Python, you'd use the standard syntax for determining if a value is present in any list-like object
If you
Re:Baroque doesn't begin to describe it (Score:1)
So I have to ask, what are your feelings on perl? It has several ways to achieve the same thing. However, at the same time you could know a small subset very well and be able to acomplish most any task?
My current job doesn't really require me to do that much scriping, but when it does, I usually go to perl. I've never used python although it seems to be a good alternative. Also, even though
Re:Baroque doesn't begin to describe it (Score:2)
We use Python for full-blown application development and have been very pleased with the results. If you're interested in trying i
Re:Baroque doesn't begin to describe it (Score:1)
Exactly.
While I do understand that different languages have strengths and weaknesses. At least with the type of pro
Re:Why I don't like PHP (Score:2, Insightful)
Yes there is: error_reporting(E_STRICT);
Embedding PHP in Python web applications (Score:2)
If you're interested in this, you'll probably be interested to know about Ian Bicking's work on embedding PHP in Python web applications [ianbicking.org] via PHP's FastCGI support. It's only in the experimental stages, but it's very promising, especially for developers like me who develop with Python but need to support legacy PHP code.
been there done that (Score:1)
Save $18.50 by buying the book here! (Score:1, Informative)
PHP is not just for the web (Score:5, Interesting)
!#/usr/bin/php
echo "Hello, world!";
Now consider that PHP ships standard on virtually every Linux distro and comes with a large assortment of libraries. You can write LDAP scripts, do IMAP, generate images, the list is loooong. It amazes me that PHP isn't used more in corporate envirments. PHP is easy to use, arrays are surprisingly useful, and you can do a little OO (which is just the right amount IMO). And something that a lot of people take for granted is that the documentation on php.net is great. Everything is on one place unlike other languages (e.g. Python) where you just get redirected to every little sourceforge scribble and wiki there is.
I'm a C person. I'll continue to use C for heavy lifting but you also need a good scripting language. I just wrote a Zend extension to interface with some of my C work and it exceeded all of my expectations.
If you're looking for the lastest hot new "technology" then Ruby is a good buzzword. Otherwise, if you're just looking to get work done, so you can go home and play with your kids, PHP is a workhorse.
PS: I don't know spit about this book but the tutorial on writing extensions on the Zend website was pretty good. Good enough for me anyway.
Re:PHP is not just for the web (Score:1)
In 1997, they "retro-fitted" a new name to it: PHP: Hypertext Preprocessor, and thus it now sits (linguistically) with GNU, et al.
Re:PHP is not just for the web (Score:2)
Re:PHP is not just for the web (Score:2)
Re:PHP is not just for the web (Score:2)
GAH! (Score:2)
Re:PHP is not just for the web (Score:2)
I use PHP extensively as a Unix scripting language. It performs quite well, even running a collection of scripts for an extended time as a daemon. You might be surprised how efficient PHP is at handling very large arrays running in memory.
And yes, it is a workhorse. It may have a few oddities and rough edges, but mostly it just stays out of the way and lets you work.
Re:PHP is not just for the web (Score:2)
I'm a PHP developer but I also write Perl and C as part of my daily job. I use PHP for all my web development, anything that has a web front end will undoubtedly be written in PHP though I have done Perl and C for web (I still hate cgi). Perl I use mainly for sysadmin type applications, easy way to automate my tasks when they're more complex than a simple BASH script will do (database con
Re:PHP is not just for the web (Score:3, Insightful)
If you're looking for the lastest hot new "technology" then Ruby is a good buzzword. Otherwise, if you're just looking to get work done, so you can go home and play with your kids, PHP is a workhorse.
No, it isn't.
Sorry, but this post sounds very blinkered. You are ignoring the 'elephant in the room'. T
Re:PHP is not just for the web (Score:1)
Ouch. That hurts. That's just not true. You may wish it to be true, but it isn't. Not when you compare it to CPAN.
Re:PHP is not just for the web (Score:1)
"The workhorse is now Java. It has unmatched support for databases, unparalleled library support."
What's really sad about the above statement is that I can't tell if the author was being serious, or intentionally outlandish.Re:PHP is not just for the web (Score:1)
Eh... PHP isn't exactly installed as widely as Perl, Python or even Ruby on non-web-server machines. And I usually see PHP just installed as Apache mod_php rather than the CGI interpreter.
Also, I'm kind of divided on whether the "everything in one place" is actually true. PHP can be compiled with different modules. So can other scripting languages, actually. Installing the stuff that's missing from your site's particular bit is either surprisingly simple if you're root (apt-get install php5-whatever) or s
Antimatter for teh haters (Score:3, Interesting)
[very offtopic] (Score:2)
Wow. That'd have been the story of my adolescence to the letter, if my otherwise fine secondary school hadn't been an IT wasteland. I got a start in BASIC back in primary school, and was eager to take it further when I moved on. The first chance I got, I logged in and opened the first recognisable name I could see: Visual Basic.
And thus endeth my programming career until the lazy days of university some eight years later.
Re:Antimatter for teh haters (Score:1)
I hate PHP. (Score:2)
I remember when I picked up PHP. It was brilliant. Look at me, I can create dynamic web pages! I could do for loops, and while loops, and print out numbers without using JavaScript! And now, I can take parameters in from $_GET[], and make a proper website in only one file!
Re:I hate PHP. (Score:2)
Re:I hate PHP. (Score:2)
Bash PHP For Fun and Profit (Score:4, Insightful)
To the PHP bashers - you might succeed in selling something new but after the next guy inherits your spaghetti code they will start bashing *you*.
Don't be fooled people. Every language has it's corners. I spend 90% of my time doing C but I just spent a month doing a standard LAMP site and I just don't see what these guys are hee'n and haw'n about. PHP is just as useful today as it was on 1998 so I'm willing to bet it will be around for a long time still. Don't be influenced by some bored guy saying "it sucks" and "I hate it". That's just not intelligent criticism. Try different things and make up your own mind.
PHP has a huge install base and has served us very well for many years. Let's not forget that. The PHP bashers pushing Python and Ruby should be ashamed of themselves. Post some useful information about how Python or Ruby solves a problem you think PHP has. And no cryptic one liners thank you. Get a spine and post some useful comments.
Re:Bash PHP For Fun and Profit (Score:2)
PHP is not "more" extendable than other languages (Score:1)
PHP isn't the first language with MySQL bindings. It's not the first with GD bindings. And so on.
And PHP wasn't really designed to be easy to properly embed in other applications either. It was designed to have the code embedded in HTML, granted. And it was designed to run in the web server. But I doubt it was designed to be put to all kinds of use. Who is embedding PHP except for web servers?
If you want a language that was really designed for embe
Re:I'd rather see a review (Score:1, Insightful)
Re:slashdot == teenage hangout (Score:1)