Answers for "file get contents php alternative"

PHP
7

php get file contents

<?php
file_get_contents("file.txt");
?>
Posted by: Guest on May-12-2020
1

file_put_contents alternative php

<?php
// this is an alternative for file_get_contents
// using Curl >

function url_get_contents ($Url) {
    if (!function_exists('curl_init')){ 
        die('CURL is not installed!');
    }
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $Url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $output = curl_exec($ch);
    curl_close($ch);
    return json_decode($output,JSON_OBJECT_AS_ARRAY);
}

?>
Posted by: Guest on August-09-2021

Browse Popular Code Answers by Language