Toggle navigation
Genres
Frontend (2)
JavaScript (6)
Database (2)
Linux Server (3)
Web Apps (4)
Misc (4)
Search
List
New Tutorials
Last Modified Tutorials
</>
Code examples
code
smiko
backend
php
phpquery
example
integration.php
integration.php
<?php //*** URL: /assets/php/phpquery/example/integration.php include ('../phpQuery-onefile.php'); // $doc = phpQuery::newDocumentHTML($markup); // $doc = phpQuery::newDocumentXML(); // $doc = phpQuery::newDocumentFileXHTML('test.html'); // $doc = phpQuery::newDocumentFilePHP('test.php'); // $doc = phpQuery::newDocument('test.xml', 'application/rss+xml'); // this one defaults to text/html in utf8 //load base layer $layer=phpQuery::newDocumentFile('template.html'); //insert html block (from file) into layer $block=phpQuery::newDocumentFile('block.html'); $layer['p']->html($block); //insert html string into layer $str='<br><b id="boldy">BOLD text after link</b>'; $layer['p']->append($str); //append into #boldy $layer['#boldy']->append(' additional text'); //replace text $layer['#replaced']->text('<i>New text has replaced old text. Use html() insted text() method in order to render HTML tags!</i>'); //load part of external page into layer $ext=phpQuery::newDocumentFile('http://www.smiko.info'); $layer['#ext']->append($ext['body #nv']); //load only element with id='nv' from www.smiko.info //modifing HTML attribute $layer['body']->attr('style','background-color:#fdd'); //dont work $layer['body']->css('background-color','#fdf'); //remove HTML p tag $layer->find('#removed')->remove(); //remove tag inside HEAD (view source code in browser) $layer->find('[href="favicon.ico"]')->remove(); //add new tag inside HEAD tag - at the end of tag $layer['head']->append('<link rel="stylesheet" type="text/css" href="appended_at_end.css">'); //add new tag inside HEAD tag - aafter googlebot tag $layer['[name="googlebot"]']->after('<link rel="stylesheet" type="text/css" href="appended_after_googlebot.css">'); $layer['[href="appended_after_googlebot.css"]']->after("\n\n"); $layer['[href="appended_after_googlebot.css"]']->before("\n\n"); echo $layer; ?>
Reload page
Preview
W3C validation
Edit Code