What are some popular SMS gateway services that can be used with PHP for sending messages?

When integrating SMS functionality into a PHP application, you can use popular SMS gateway services such as Twilio, Nexmo, or Plivo. These services provide APIs that allow you to send SMS messages programmatically from your PHP code. By signing up for an account with one of these services, you can obtain API credentials and start sending SMS messages to your users.

// Using Twilio as the SMS gateway service
require __DIR__ . '/vendor/autoload.php';
use Twilio\Rest\Client;

// Your Twilio account SID and auth token
$account_sid = 'YOUR_TWILIO_ACCOUNT_SID';
$auth_token = 'YOUR_TWILIO_AUTH_TOKEN';

// Initialize Twilio client
$client = new Client($account_sid, $auth_token);

// Send an SMS message
$message = $client->messages->create(
    'RECIPIENT_PHONE_NUMBER',
    array(
        'from' => 'YOUR_TWILIO_PHONE_NUMBER',
        'body' => 'This is a test message from Twilio!'
    )
);

echo 'Message sent: ' . $message->sid;