PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I am working with codeigniter .2.1 and twitter bootstrap to develop a site. I used php's domdocument to generate some dynamic html which I want to insert into a page.Unfortunately , the php generated fragment is now the first thing on the page when I look at the html source:
$dom = new DOMDocument('1.0'); //Create new document with specified version number
$div= $dom->createElement('div') ;
$dom->appendChild($div);
$h3=$dom->createElement('h2','Available Now:');
$div->appendChild($h3);
echo $dom->saveHTML();
So, if I understand correctly, this means we are using xml version="1.0".
Please note that I have another section of code (which I did not include above) that produces a second fragment of html which is included in the original html fragment I showed in my first post. it also starts with:
<?php
$dom = new DOMDocument('1.0'); //Create new document with specified version number
$div= $dom->createElement('div') ;
$dom->appendChild($div);
$h3=$dom->createElement('h2','Available Now:');
$div->appendChild($h3);
echo $dom->saveHTML();
?>
Is there a specific reason why you have this above the doctype declaration
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
public function index()
{
$this->load->view('header'); // static HTML including doctype declaration
$this->load->view('navbar'); // static HTML
$this->load->view('hero_unit'); // static HTML
$this->currentItems(); // my generated HTML ( which we are discussing )
$this->load->view('footer'); // static HTML
}
Ok; well my knowledge of both DOMDocument and codeIgniter are non-existant so an alternative i can offer is to refer you to a tutorial on the codeIgniter site; Hth http://codeigniter.com/user_guide/tutor ... pages.html
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering