[英]Save HTML to database and later add PHP links
Hello i am storing html into database. 您好,我将HTML存储到数据库中。
Next i am querying results with codeIgniter 接下来我要用codeIgniter查询结果
<?php echo($lekcija[0]->tekst);?>
Problem is in my html i have images and i wanna for src and php created link 问题是在我的html中我有图像,我想为src和php创建链接
<img src="/images/mysql-kako-instalirati-mysql.JPG" alt="Kako instalirati MySQL ?">
Something like this 像这样
<img src="<?php echo base_url();?>/images/mysql-kako-instalirati-mysql.JPG" alt="Kako instalirati MySQL ?">
But i have problem php is rendered as HTML any idea how to override this? 但是我有问题php呈现为HTML任何想法如何重写此?
Use a place holder and than replace it when you serve the page, example: 使用占位符,而不是在投放页面时将其替换,例如:
<img src="{BASE_URL}/images/mysql..." alt="..." />
All you have to do is replace {BASE_URL}
with whatever code you want in place of it using a PHP replace function or whatever you prefer at that point. 您所需要做的就是使用PHP替换功能将{BASE_URL}
替换为所需的任何代码,或者使用此时需要的任何内容替换。
Why not following the good practise as suggested.. 为什么不遵循建议的良好做法。
echo img(array('src'=>'/images/mysql-kako-instalirati-mysql.JPG', 'alt'=> 'Kako instalirati MySQL ?'));
If you have the image path in $lekcija[0]->tekst
? 如果图像路径位于$lekcija[0]->tekst
?
then it would be 那会是
echo img(array('src'=>'/images/'.$lekcija[0]->tekst, 'alt'=> 'Kako instalirati MySQL ?'));
Learn more about Codeigniter helper from here 从此处了解有关Codeigniter助手的更多信息
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.