1<?php
2//str_replace("Original Value", "Value to be replaced", "String");
3$result = str_replace("1", "2", "This is number 1");
4// Output: This is number 2
5?>
1// Require_once is ignored if the required file has already been added by any of the include statements.
2<?php
3 require_once 'require_oncefile.php';
4?>
1$opts = [
2 "http" => [
3 "method" => "GET",
4 "header" => "Accept-language: en\r\n" .
5 "Cookie: foo=bar\r\n"
6 ]
7];
8
9// DOCS: https://www.php.net/manual/en/function.stream-context-create.php
10$context = stream_context_create($opts);
11
12// Open the file using the HTTP headers set above
13// DOCS: https://www.php.net/manual/en/function.file-get-contents.php
14$file = file_get_contents('http://www.example.com/', false, $context);
1function url_get_contents ($Url) {
2 if (!function_exists('curl_init')){
3 die('CURL is not installed!');
4 }
5 $ch = curl_init();
6 curl_setopt($ch, CURLOPT_URL, $Url);
7 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
8 $output = curl_exec($ch);
9 curl_close($ch);
10 return json_decode($output,JSON_OBJECT_AS_ARRAY);
11}