Php函数HTML参数中心

时间:2017-04-08 18:11:20

标签: php html function

我相信我会因为这个问题而得到很多坏点。

但我知道这有效:

<?php
function line(){ ?>
2(Out of php)
<? } ?>
   1(Out of php)
<?php
echo line()
?>

但这些不起作用:

<?php
echo line( ?> text html <?php ); ?>

或者:

<?php
$html = ?> text html <?php ; ?>

在有人向我扔石头之前,我会解释。我想创建一个创建引导程序的div结构的函数,但这些div将有很多内容,我不想在php变量中写这个,或者不得不记得调用一个函数来关闭标签

function divs($size, $html){ return 'Many divs('.$size.'%)'.$html.'Closing many div'; } 

//something like that
echo divs(40, ?> many many many html content <?php );

//I do not want to write as much string content
echo divs(40, 'many many many html content' );

感谢您的其他想法。

1 个答案:

答案 0 :(得分:0)

在PHP中打印html中打印PHP更容易。例如,

<?php

function line(){

...code code code

?> 

<div> <?php echo $info ?> </div>

...hmtl html <?php echo $info ?> html
...hmtl html <?php echo $info ?> html

<?php 

...continuity of code
?>

<script type="text/javascript">
jsFunction();
</script>

<?php
}

?>