title: How Do I Build My First PHP Extension in C on Linux GCC?
body: <p>I haven't used C since the 1980s and 1990s with my own experimentation. I'd like to be able to pick it up again, but this time by building small things in it and then loading it into PHP on Linux.</p>
  
  <p>Does anyone have a very short tutorial for me to make a foo() function in C as a shared object extension loaded in a php.ini? I assume I'll need to use the GCC, but don't know what else I need on my Ubuntu Linux workstation to get this going, or how to compose the files. </p>
  
  <p>Some of the examples I've seen have shown how to do it in C++ or show it as a static extension that must be compiled into PHP. I don't want that -- I want to do it as a C extension, not C++, and load it via php.ini.</p>
  
  <p>I'm thinking of something where I call foo('hello') and it returns 'world' if it sees the incoming string is 'hello'.</p>
  
  <p>For instance, if this was written in 100% PHP, the function might be:</p>
  
  <pre><code>function foo($s) {
    switch ($s)
      case 'hello':
        return 'world';
        break;
      default:
        return $s;
    }
  }
  </code></pre>