开发者

php dom problem

开发者 https://www.devze.com 2022-12-23 20:59 出处:网络
hello I\'m new to PHP programming a开发者_C百科nd I migrated from ASP .net to PHP.. I have a div just like below

hello I'm new to PHP programming a开发者_C百科nd I migrated from ASP .net to PHP..

I have a div just like below

<div id="mydiv"></div>

what I wanted to do is just to change the text and html content(like some name or any data in it) in it.

What I imagine is just like

mydiv=>innertext="some value";

Thanks, GURU


Are you trying to modify the div in the same page as the php? I don't think that's possible.

PHP runs at the server, and only sees content between the php tags.

If you're modifying dom content, it seems like javascript/jQuery is a better approach for this.

Otherwise, if you're modifying content that is hosted already, and plan output it to a different page, then you can use this:

PHP Simple HTML DOM Parser


$myDivText = "This is what goes inside mydiv";

echo "<div id=\"mydiv\">$myDivText</div>";

0

精彩评论

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