highlight "<?php" ---- "?>" inside "<html>" --- "</html>" in notepad++? [duplicate] - php

This question already has answers here:
Is there anyway to have Notepad++ highlight both PHP and HTML at the same time?
(2 answers)
Closed 7 years ago.
<html>
This is file is called "example.php".<br>
<?php print "=== This is printed by a php 'print' statement<br>"; ?>
This text is after the embedded php.
</html>
When either of the html tags, its mate is found, and both are given a distinctive color.
But the php tags don't find their mates, and don't get highlighted. How can I get that behavior?

Save your file in .php extention in notepad ++.
If that does not sort the problem download the latest version of notepad++ from here.
Here : it works see :) -
Let me know if anyother issues :)

Related

PHP preg_replace is outputing me the wrong result [duplicate]

This question already has answers here:
How to show <div> tag literally in <code>/<pre> tag?
(11 answers)
Closed 2 years ago.
Im actively practicing with php regex and got stuck with a replace function as it shows absolutely different results from tutorial I copied it from.
So the function preg_replace('/\{([a-z]+)\}/', '(?P<\1>[a-z-]+)', '{controller}\/{action}') should give me this result in the output: (?P<controller>[a-z-]+)\/(?P<action>[a-z-]+). phpliveregex.com confirms that https://www.phpliveregex.com/p/wIF
However, this is what my browser on my localhost is outputing me in fact: (?P[a-z-]+)\/(?P[a-z-]+).
How is that possible? Is my php broken or the preg_replace function is working differentely now? My php version is 7.4.4
Your browser interprets the <controller> and <action> as html tags and tries to parse them that leads to deleting them. see this to see how can you show tags literally using html encoding.
(?P<controller>[a-z-]+)\/(?P<action>[a-z-]+)
<br/>
(?P<controller>[a-z-]+)\/(?P<action>[a-z-]+)
You can maybe replace it with (?P<\1>[a-z-]+)

How can I put an opening and a closing PHP tag in an echo? [duplicate]

This question already has an answer here:
How can we include php tag in html with php echo [closed]
(1 answer)
Closed 10 years ago.
I already post this question before but people always ask unnecessary question. I'm gonna explain it in a simple way.
I HAVE 3 files :
a php file (contains only html, thats important) : We call it X file for the example.
a php file where there's some database query to insert database data on the screen : Y file
a php file (a script that will make some manipulations) : Z file
SO, i want to include Y into X with the script of Z.
In Z, i make a str_replace($text, $new, file_get_contents($file));
The ONLY THING is that i need to include PHP open and close TAGS in X because there's no php tags in it.
So, $new = "<?php include('Y.php'); ?>";.
If you try, the close tag wont be considered in the string, but that's what i want.
Hope this question is NOW clear. I can't be more clearer than that. :D
Thanks for you advice.
You need to replace the < and > characters with their HTML entities:
<?php echo "<?php include('this.php'); ?>"; ?>
If you want to include the file, there's no need for the above, running the code below is more than sufficient:
<?php
include('this.php');
?>
You don't have to use two lots of PHP tags...
I may as well put this as an answer.
If you don't want to manually replace < and >:
<?php echo htmlentities("<?php include('this.php'); ?>"); ?>

Any solve there to not execute </textarea> tag(which contained $values)? [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
How to properly escape html form input default values in php?
I am facing problem on facing </textarea> element.
I am working on whole php file edit. If the php file has </textarea> tag it closes the files codes.
E.g.
$data=file_get_contents($file);
..
'<textarea>'
'.$data.'
'</textarea>'
..
The problem is:
if contain the </textarea> tag in data, my codes truncted by the tag. Because </textarea> is end tag of textarea values. Any solve there to not execute </textarea> tag(which contained $data)?
Try cleaning up $data before outputting it, such as:
'.htmlentities($data).'
Also, take a look at the available flags for the function in the PHP documentation.

Remove the unwanted commented code copied from word using php [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
PHP to clean-up pasted Microsoft input
Need to remove the code in comments
[if gte mso 9]><xml> <w:WordDocument> ..... --> [endif] -->
from my db field, when copying text from word and saving this unwanted code is coming.In Ie the source after this was not displaying as it causes display problems
try this:
$clean_string = preg_replace("/(\[if\s.*?\].*?\[endif\]\s*-->/)","",$dirty_string);
If thats the exact string you would like to clean then you can use something like this
$clean_string = preg_replace("/(\[if.+?\[endif\]\s{0,}-->)/","",$dirty_string);
Example here
http://ideone.com/cf0MG
Updated ideone link
http://ideone.com/08L6L
Take a look at the paste plugin:
[paste_remove_styles] If true, removes all style information when pasting, regardless of browser type. Pasting from Word 2000 will cause tinyMCE to error. Default is false.

php include ÅÄÖ = ??? / UTF8 problem [duplicate]

This question already has answers here:
UTF-8 all the way through
(13 answers)
Closed 2 years ago.
index.php
<?php
include("header.php");
?>
header.php
<?php
echo"<a href='add.php'>Lägg Till</a>";
?>
result
L?gg Till
The document is utf8 within the head tags and all, it's a php thing, the problem only occurs when i get text from include, i cannot have ÅÄÖ in included php files , how do i make it work?
Save these files in utf-8 too
when sending text to server with accents letters use always ut8_encode, in you case:
echo utf8_encode("<a href='add.php'>Lägg Till</a>");
I have the same problem and this on solves them.
Besides saving the file in UTF-8 you could also check the "default_charset" configuration in the php.ini file.

Categories