What are some common functions or techniques in PHP for grabbing content from external websites?
When you need to grab content from external websites in PHP, you can use functions like file_get_contents() or cURL to fetch the data. These functions allow you to retrieve the HTML content of a webpage and then manipulate or display it as needed.
// Using file_get_contents() to grab content from an external website
$url = 'https://www.example.com';
$content = file_get_contents($url);
// Display the content
echo $content;
```
```php
// Using cURL to grab content from an external website
$url = 'https://www.example.com';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$content = curl_exec($ch);
curl_close($ch);
// Display the content
echo $content;