我有用于编写自定义短代码的代码。但是它返回此错误消息。如何克服这个错误。
[注意:我也尝试过在启动html之前关闭php标签,并在结束html之后再次启动它]
pi@raspberrypi:/tmp $ valgrind ./a.out < f
==14583== Memcheck, a memory error detector
==14583== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==14583== Using Valgrind-3.13.0 and LibVEX; rerun with -h for copyright info
==14583== Command: ./a.out
==14583==
AQBRCSDTEFPG
abcdefghijklmnopqrstuvwxyz
==14583==
==14583== HEAP SUMMARY:
==14583== in use at exit: 0 bytes in 0 blocks
==14583== total heap usage: 11 allocs, 11 frees, 5,772 bytes allocated
==14583==
==14583== All heap blocks were freed -- no leaks are possible
==14583==
==14583== For counts of detected and suppressed errors, rerun with: -v
==14583== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 6 from 3)
Parse error: syntax error, unexpected '<' in C:\xampp\htdocs\theme-dev\wp-content\themes\sportify\functions.php on line 77
答案 0 :(得分:0)
错误是因为您尝试在php块中输出html。您必须使用php end / start标记
// Add Shortcode
function custom_shortcode() {
ob_start();
?>
<div class=intro> ... </div> //... exactly the code you got now
<?php
return ob_get_clean(); //ob_get_clean() is returning everything you echoed or rendered since ob_start()
}
add_shortcode( 'kollol', 'custom_shortcode' );