我需要编写一个代码,允许我发送一个数组中的特定链接。这是我想要做的一个简短的想法。根据国家代码,我会用特定的语言发送小册子。我也想知道如果我可以通过开关做到这一点...如何发送数组中的特定链接?
这是我到目前为止的代码...
<?php
$de_brochure = ('https://ruta/de-brochure.pdf');
$en_brochure = ('https://ruta/en-brochure.pdf');
$es_brochure = ('https://ruta/es-brochure.pdf');
$country_code = 'ES'; // Normally I get this code from a form.
$brochure = array ($de_brochure, $en_brochure, $es_brochure);
$brochure_link = '';
if ($country_code == 'ES') {
$to = '[email protected]';
$subject = 'Ejemplo';
$txt = 'El dossier a enviar es' . $brochure_link[$brochure];
$headers = 'De: [email protected]' . '\r\n' .
'CC: [email protected]';
mail ($to, $subject, $txt, $headers);
} else {
echo $country_code . 'no es el código de españa';
}
当我运行我的代码,这是我得到的输出:
警告非法偏移类型上的行号17
注意未初始化的字符串偏移量:行号1 17
好,'$ brochure_link'是一个字符串,而不是一个数组,所以'$ brochure_link [$ brochure]'会引发错误。 – roberto06
你期望什么?没有数组'$ brochure_link'索引'$ brochure_link [$ brochure]' – C2486
如果我知道该怎么做我瘦我不会问@Rishi谢谢你这么有礼貌。这只是一个想法,我想要帮助解决这个问题。 – KAZZABE