How can I replace /> with > For example; I need this: <img src=""> not <img src="" /> HTML: XHTML needs " />" at the end of HTML codes. But I moved to HTML doc type from XHTML and the pages became not valid. I found this: http://php.net/manual/en/function.str-replace.php but couldn't write a code.
Nothing to test This will work <?php $string= "<img src=\"\" />"; $string= str_ireplace("/>",">",$string); ?> PHP:
You don't need str_Ireplace as theirs nothing to replace thats case insensitive, furthermore consider using preg_replace for reliability.
I tried preg_replace too but they don't work. They don't change "/>" and " />" as ">" I added your codes to several php files of WP. I also couldn't find a wp plugin for this. I removed the tick from the box in front of "WordPress should correct invalidly nested XHTML automatically" at wp-admin/options-writing.php but it is still adding " />" and validate the HTML codes as XHTML doc type. It was upgraded to the latest version, wp 3.0. I found this plugin: http://wordpress.org/extend/plugins/validation-helper/ but "THIS PLUGIN IS NO LONGER SUPPORTED!" I am starting to think it is impossible to have a WP with HTML doc type.
I want to test HTML 4.01 Transitional as I can't validate the strict version. I recently noticed that all of my sites are with XHTML except the one which I purchased a while ago. It's a very simple custom design site with no database and feeds. It has very few content, less than 50 pages in total. But it always gets higher SERPs with a few very poor SEO. I strongly suspect from its HTML doc type. I changed the doc of my WP site but I can't validate it. This is an auto-post wp site with more than 10k pages indexed. If I can validate the pages, this will be a very good test and will show me the effect of doc type over SERPs.
I have just noticed that most of the biggest sites including yahoo, google, youtube, wikipedia, etc. use HTML doc types. You can check the other biggest sites: http://www.alexa.com/topsites There must be a good reason behind this. That's why I want to try HTML.