Skip navigation

Tag Archives: php

I installed PHP with all extensions. The extensions sometimes fail and prevent php from booting.

ON PHP 5.3.4, Apache 2.2.17 as of today, the following extensions don’t work by default and need to be commented out.


Trying to install Apache 2.2 and PHP on a Windows 7 x64 system, I got this error:

[crit] (OS 1813)The specified resource type cannot be found in the image file. : master_main: create child process failed. Exiting.

What you have to do is open PHP.ini and go to the bottom of the file and start commenting out extensions.

Basically some of the extensions don’t work, so you have to keep commenting them out until you find the culprit.

Best to keep it to the bare minimum extensions you know you will use..

Q: How do I do an overloaded constructor in PHP?

A: You don’t need them

Consider the following

class Foo
  var $name ;
  function __construct()
    # if the default ctor is invoked, name
    # this instance "unnamed"
    $this->name = 'unnamed' ;

  # Fine and dandy, but what if
  # we want to supply a name
  # in an overloaded ctor?
  function __construct( $iname )
    $this->name = $iname ; #doesn't work
    # because overloaded ctors of this style
    # aren't supported in PHP!!

OK. Well I promised in the title of this post that you didn’t need overloaded constructors in php Here’s why.

Redefine class Foo as follows:

class Foo
  var $name ;

  # specify a single ctor, WITH DEFAULT VALUES
  # FOR PARAMETERS.  This is equivalent, and in my
  # opinion a better syntax
  # for getting overloaded constructors to work.
  function __construct( $iname = 'unnamed' )
    $this->name = $iname ;

There. Fewer lines of code, less mess, same effect. This was an excellent design decision by the php group.

wow! that was fun.

This is how you do it, using Sara Golemon’s Extending and Embedding PHP as a reference (a fabulous book, by the way).

  1. create a folder on your c drive, like C:\PHPDEV
  2. download php 5.2.6 source from a mirror (this is the current php 5 version, time of this post). Save this tar.gz file into C:\PHPDEV. EXTRACT IT THERE.
  3. download php win32 build extras and save into C:\PHPDEV. EXTRACT IT THERE.
  4. Get pre-built binary packages for bison.exe and flex.exe. Put those on your desktop, or somewhere AWAY from C:\PHPDEV.

    Open both archives and go into their /bin directories. Take flex.exe from the flex archive and bison.exe from the bison archive and put THOSE into C:\PHPDEV.

  5. The next step can get twisted if you don’t have Visual Studio (any version?) installed.

    If you don’t have it, try the express editions, or take a look at article.

    Assuming you have Visual Studio 2008, FIRST, open C:\Program Files\Microsoft Visual Studio 8\Common7\Tools\vsvars32.bat.

    The file is about 50 lines long full of @set type statements.

    Find the line that starts with

    @set PATH=C:\Program Files\Microsoft Visual Studio 8\Common7\IDE;(goes on)

    Change that line to read

    @set PATH=C:\PHPDEV;C:\Program Files\Microsoft Visual Studio 8\Common7\IDE;(leave the rest exactly as it were)

    So all I did there was add C:\PHPDEV; just after the = sign. The reason I did that was so that flex.exe and bison.exe are part of the system path now.

    NOW, go to Start->Microsoft Visual Studio 2008->Visual Studio Tools->Visual Studio 2008 Command Prompt.

  6. switch to C:\PHPDEV\php-5.2.6
  7. type buildconf.bat
    What this does is scan all folders for .w32 files and creates configure.js for you
  8. type:
    cscript /nologo configure.js --without-xml --without-wddx --without-simplexml --without-dom --without-libxml --disable-zlib --without-sqlite --disable-odbc --disable-cgi --enable-cli --enable-debug --without-iconv --disable-ipv6


    what this does is modify configure.js for you. You can get the same effect I guess by going into configure.js and manually setting things to “yes” and “no”. Why disable all these things? Most of these aren’t included in the bundle you downloaded, so you’d get compile errors like “file not found” if you didn’t disable these.

    if you don’t have bison.exe, you’ll get:

    ERROR: bison is required

    If you don’t have flex.exe, you’ll get

    ERROR: flex is required

    so get bison and flex as explained above.

  9. Type


  10. switch to c:\PHPDEV\php-5.2.6\Debug_TS
  11. Type something like

    php -r “$x = ‘hello’; echo($x);”

Sara, you are fantastic. The book is rich and explains things very clearly. I had to skim through some of the stuff about php life cycle and php variables, because I was anxious to build it, but there’s tons more to read here :). Seems to be fairly considerate to windows users. Thanks for writing that book, to begin with.

online guide
another article –
Elizabeth Smith