开发者

(PHP+HTML) Codes inside PHP

开发者 https://www.devze.com 2023-03-29 05:35 出处:网络
I have some coding which has both PHP & HTML tags... it is a very big coding... now i want to add these coding inside PHP tag... i tried using \"echo\" statement and adding quotes, concatenation..

I have some coding which has both PHP & HTML tags... it is a very big coding... now i want to add these coding inside PHP tag... i tried using "echo" statement and adding quotes, concatenation... it doesnt work and showing some error

here is a sample line..

<td>Developer</td><td>:</td><td><?php echo wpws_get_content($url,'.doc-header-link','','user_agent=FairAndroid.com&on_error=error_hide&cache=43289&callback=call')?></td>

the above line has lots of quotes, html and php... i have lots of lines like this...

what is the best way to include (HTML开发者_开发百科 & PHP) inside PHP ??


there's nothing wrong with your line. Follow error you're seeing and try to correct them

http://sandbox.phpcode.eu/g/3a329.php


"adding quotes, concatenation" That's what you need, but it's kind of error-prone to reformat long lines:

echo '<td>Developer</td><td>:</td><td>'
    . wpws_get_content($url,'.doc-header-link','','user_agent=FairAndroid.com&on_error=error_hide&cache=43289&callback=call')
    . '</td>';


This is just a suggestion so that no matter how long your html codes just a simple include will simply insert it to your php file.

  1. Put you html codes in a different file
  2. Then just include it in your php file.

file.html

<p>Hello World!</p>

file.php

<?php

include("file.html");

?>


Assuming you want to print that chunk of code, you failed to escape the quotes and the special characters ( <, >, & and so on).

Splitted on multiple lines for better clarity.

<?php
    echo('<td>Developer</td>');
    echo('<td>:</td>');
    echo('<td>&lt;?php echo wpws_get_content($url, \'.doc-header-link\', \'\', \'user_agent=FairAndroid.com&amp;on_error=error_hide&amp;cache=43289&amp;callback=call\')?&gt;</td>');
?>
0

精彩评论

暂无评论...
验证码 换一张
取 消