PHP Quickstart: Saying a Message

Let's walk through creating your first application, Hello Monkey. We'll use PHP to construct this example, but almost any web development language could be used.


  1. To begin, you'll need a Twilio inbound phone number. You can use a free Twilio trial account or upgrade your account and get your own dedicated phone number.
  2. You will also need a web host that lets you host PHP applications. There are lots of web hosting services that with host your PHP application for a few dollars a month.


You can download the (minimal) code used in this example if you want:

Hello Monkey, v1.0

  1. Let's say your web server answers HTTP requests at Create a file called hello-monkey.php in the document root. The URL should be and will be the initial voice URL for your phone number.
  2. Browse to the Phone Numbers page in your account on the Twilio website. If you don't already have a Twilio phone number, you can purchase your own phone number using the "Buy a Number" button on the right hand side of the page. Click the "Edit" link next to the phone number you would like to use. Next, check the "Voice" box, and paste the URL of your hello-monkey file (e.g. in the "URL" box. Hit save and this phone number will now point to your new hello monkey code.
  3. Now, open up the hello-monkey.php file on your web server. Let's start with this basic php example code:
    header("content-type: text/xml");
    echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
    <Say>Hello Monkey</Say>

Now, pick up your mobile or landline phone and dial the number of application. Twilio will now fetch your URL, in our case, and execute the XML instructions above. First, it will Say 'hello monkey' and then it will hang up because there are no more instructions.

Next: Greet caller by name »

Need some help?

We all do sometimes; code is hard. Get help now from our support team, or lean on the wisdom of the crowd browsing the Twilio tag on Stack Overflow.