Sometimes we need to decode HTML entities from any specific strings in PHP. Basically it’s more used for retrieve HTML entities from a MySQL cell.? To Convert all HTML entities to their applicable characters there is one function available that is called html_entity_decode(). html_entity_decode($YourStrings) Example: <?php $orig?=?"I'll?"love"?the?<b>girl</b> very much"; $a?=?htmlentities($orig); $b?=?html_entity_decode($a); echo?$a;?//?I'll?"love"?the?<b>girl</b> very much echo?$b;?//?I'll?"love"?the?<b>girl</b> very much?>
Category: Programming
Read articles, tips & tutorials, news and updates on programming language. I write on mostly all languages and try to share my experience with you so you don’t need to spent too much time to find the solution by yourself. Sharing is the true power of knowledge.
When you will work with your Blog or something in PHP, MySQL. Then your user may enter apostrophe s (‘s) into the post writing area. Then it will cause a problem for executing your MySQL Query. To execute your query for MySQL you can use mysql_real_escape_string($yourStrings). Example: <form method=”post” action=””> <input type=”text” name=”user_name” value=”wallpaperama’s”> <br /> <br /> <input type=”submit” name=”Submit” value=”Submit”> </form> <?php $user_name = mysql_real_escape_string ($_POST[‘user_name’]); ?> and write your mysql query. It will be executed without any …
Sometimes when you make many functions in your PHP scripts. Then you need to check the real existence of the function you need. That’s why to check a function’s existence, you can write a little piece of code like the following: <?php if(function_exists(NameOfTheFunction)) { echo "Function Exist"; } else { echo "Function doesn't exist"; } ?> NameOfTheFunction means your function's name. If your function is LoginCheck(). Then you need to write only LoginCheck. Just omitt the () symbol. If it …
To write values or text in a .txt file you can follow the following process in PHP. <?php function test_function () { return ?"Hello!"; } $function_contents = test_function (); $file_name = "test_file.txt"; $file_handle = fopen($file_name, 'w'); fwrite($file_handle, $function_contents); fclose($file_handle); ?> It will make a text file named test_file.txt and in that file this PHP code snippet will write ‘Hello’. Thanks
To start writing JavaScript in your HTML page, it’s really easy. Just start to write <script type=”text/javascript”> and make a end of this javascript code snippet by </script> closing tag. Try to have a look as following and open your notepad and start writing HTML page with the following little bit JavaScript code snippet. <html> <body> <script type=”text/javascript”> document.write(“Hello World!”); </script> </body> </html>