-5

我是 PHP 编程新手。运行以下 PHP 代码生成 URL 时出现此错误。我使用 PHP 5.3.5。

( ! ) 解析错误:语法错误,意外的 T_CONSTANT_ENCAPSED_STRING,在第 30 行的 C:\wamp\www\test\urlgen.php 中需要 '&' 或 T_VARIABLE

function bg_gen_secure_uri(
    'http://demo.com/abc/secure/movie/movie-full-film_256x144-150.mp4',
    'MqG9$fso2lt7(',
    $expiry = 0,
    $allowed_countries = '',
    $disallowed_countries = '',
    $allowed_ip = '',
    $allowed_useragent = '',
    $allowed_metros = '',
    $disallowed_metros = '', $progressive_start = '', $progressive_end = '',
    $extra_params = '' )
{
      return $url;
}

如果能得到答复,我将不胜感激。

4

2 回答 2

1

为什么要给两个常量作为参数?

'http://demo.com/abc/secure/movie/movie-full-film_256x144-150.mp4','MqG9$fso2lt7(',

那部分是错误的。使用某物进行赋值,可能是这样的:

<?php
    function bg_gen_secure_uri($p1 = 'http://demo.com/abc/secure/movie/movie-full-film_256x144-150.mp4', $p2 = 'MqG9$fso2lt7(', $expiry = 0, $allowed_countries = '',$disallowed_countries = '', $allowed_ip = '', $allowed_useragent = '',
    $allowed_metros = '',
    $disallowed_metros = '', $progressive_start = '', $progressive_end = '',
    $extra_params = '')


    {

     return $url;
    }
?>

而且没有<php>标签。删除那个!

于 2013-02-02T07:58:54.747 回答
1

您的函数参数必须是变量,对于默认值,您必须像这样使用:

<?php
function bg_gen_secure_uri (
$ca='http://demo.com/abc/secure/movie/movie-full-film_256x144-150.mp4',
$b='MqG9$fso2lt7(', 
$expiry = 0, 
$allowed_countries = '',
$disallowed_countries = '', 
$allowed_ip = '', 
$allowed_useragent = '',
$allowed_metros = '',
$disallowed_metros = '', 
$progressive_start = '', 
$progressive_end = '',
$extra_params = ''
)

{

 return $url;

}
echo bg_gen_secure_uri();
?>
于 2013-02-02T07:59:03.060 回答