exec()php函数无法正常工作

Amy*_*Amy -1 php

<?php
    error_reporting(0);
    session_start();
    function code($no_of_char)
        {
            $code='';
            $possible_char="0123456789";
            while($no_of_char>0)
                {
                    $code.=substr($possible_char, rand(0, strlen($possible_char)-1), 1);
                    $no_of_char--;
                }
            return $code;
        }

        function sendSms($msg, $to)
        {

        $to=trim($to);
        $m.=urlencode($msg);

   $smsurl="http://bhashsms.com/api/sendmsg.php?user=*****&pass=*****&sender=******&phone=$to&text=$m&priority=ndnd&stype=normal";

    $return = exec($smsurl);
        return $return;
        }

    ?>
Run Code Online (Sandbox Code Playgroud)

print_r($smsurl)显示我想要的绝对正确的命令,但不执行exec($smsurl) 我不熟悉的exec()功能.提前致谢.

小智 5

exec用于执行外部程序,但从web url访问某些webpage/api不是exec的有效用例.如果您想从Url获​​取数据,请尝试此操作.

如何在php中调用任何其他网站的网址