How to create HTML tags?

75 Views Asked by At

Unline phpQuery, Running

echo qp('<div>s</div>')->html();

I expect to get <div>s</div> but it returns a complete document:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html><body><div>s</div></body></html>

How do I prevent it from adding doctype, html and body tags?

Currently, as a workaround I can use qp('<div>s</div>')->top('body *')->html(); for that. But I seek a cleaner way.

2

There are 2 best solutions below

3
ceejayoz On

According to this:

echo qp('<div>s</div>')->top('body')->html();
0
ErickBest On

Just KISS (Keep It Simple and Stupid)

echo "<div>s</div>"

This will output:

<div>s</div>

Using qp for that purpose will be an overkill/and will waste your precious time for no-reason IMHO.