Send rich formatted html email with css using php mailer - php

I need to send a rich formated html with lots of css in it.. The problem with mail is that only inline css works.. and i can use that for some part of the mail. the rest is in need to highlight some codes.. which changes for every email.. what i need is some syntax highlighter that can really glow the different codes like c, c++, java, php etc with syntax colors. And i need to do that in php. What is the best server side syntax highlighter can be used.
Or else is there anyway to email a webpage completely with full css support.

Check this out: http://www.sitepoint.com/highlight-source-code-php/

There is this project on GitHub, written in Python, which takes an HTML document and converts all the styles to inline CSS. There is a web page which shows it working.
If you know Python, or know someone who does, you could probably port it to PHP without much difficulty.
I found it by Googling "convert css to inline" - it is the first result, if you look further down the results, you may find a PHP based solution.
PHP source code can be highlighted by using the highlight_string() function - I'm sure other languages provide similar functionality, and there are also projects like this one.

I used something called emogrifier which is written in PHP and it works cool.

Related

how do I find out what php function from Wordpress is generating blocks of HTML using browser inspector?

I'm developing a Wordpress site, which I'm fairly new to. I'm not sure if this is a stupid question or not but I haven't been able to return any decent google results regarding this. Anyway, is there a way to find out what PHP function is generating a piece of HTML code using a browser code inspector like Chrome's? Thanks!
No.
Once the data arrive to the browser, all the PHP code have been processed and you can't know what part of PHP generated which part of the HTML code.
No - not without modifying the php code to enable some kind of debugging. Chrome can only give you information about the received html document on the client side (you). But php code gets parsed server side.
You kind of can:
Download a copy of the theme and plugins folder
Open the page on your site that you want to find the function for.
Find a div/class that is specific to section e.g. <article>
Open a text editor like notepad++ (one that will allow you to search through multiple files at ones)
Use the find feature of chosen text editor and search for the div/class
The result will show you a list of pages where that term is.
Look through those pages for the function you are looking for (it might take a few goes)
The above it is a bit of a roundabout way of doing it, but I think other than looking through each file separately, it is you next best way.

Using geshi inside a textarea

Yes, sound weird. But I'm trying to make a text editor inside the browser. I've seen some programs use it. Like wordpress and unet. But I'm not sure if they use a custom one or not.
However, this topic explains why geshi won't work in textarea:
Why isn't textarea an input[type="textarea"]?
I simply get the code of the colors. Just wondering if there's a way around this. I've tried searching but I was without luck.
<textarea><?php geshi_highlight($source, 'php'); ?></textarea>
edit::the variable $source contains php code.
Output is basically the span style that geshi outputs.
That kind of formatting does not work in a textarea, that's one its properties. You probably want to make some HTML contentEditable, but it won't work quickly out of the box, there needs to be a mechanism where an alteration triggers new highlighting. And that would probably involve a lot of traffic to and from the server, to the point of it not being a viable solution. You probably would end up using a javascript syntax highlighter like http://jush.sourceforge.net/ or others, and I haven't actually seen a 'live' syntax highlighter editor in the wild yet (as in: only plain textareas with a syntax-highlighted 2nd box), but then again I've never been searching for it.... I like my editors local ;).

How can I get emacs to tell the difference from when I am writing PHP, HTML, and JavaScript?

When using emacs and writing PHP I sometimes need to put html in there and I would like to see a difference in highlighting from PHP to HTML. Also the same goes for if I am putting JavaScript in say an HTML file, how can I get the syntax highlighting to change?
nXhtml is the most comprehensive attempt to deal with this problem (specifically for web development) that I'm aware of.

Need a live PHP editor like dreamweaver

I am in need of a live editing software for PHP like there is DreamVeawer for CSS. I need the functionality that I can select items from the webpage and it will highlight the particular source code for it. If anyone knows about such a software please let me know.
Thanks in advance.
Firefox has a nifty add-on called Web Developer. You can't edit the PHP code directly because it's server side but you can highlight/edit the resulting HTML. You can find it here https://addons.mozilla.org/en-US/firefox/addon/web-developer/
Use google chrome's webkit inspector, it will find you the right html source code, which you can then trace back to the PHP code.
I'm afraid you won't find a solution for that.
PHP runs on the server-side and doesn't render any code to the browser like HTML does.
The closest you'll come is selecting DOM elements in Firebug/Dreamweaver(or any other designy IDE) rendered after the PHP is parsed
Im not sure what youre looking for exactly. If you want a WYSIWYG html editor they are plenty.
If youre tring to trace function and method calls in code then you need an IDE with code assist. Both Eclipse and Netbeans with their respective PHP plugins have this - i.e. you click on a function call and it opens the file containing that function. Depending on the context this can also work with variables...
I think there are also WYSIWYG html plugins for both but im not sure as i dont use them.
This isn't exactly what you want but this IDE can give a help
Aptana http://www.aptana.com/
or
PHPStorm http://www.jetbrains.com/phpstorm/

PHP function which does syntax color parsing for multiple languages?

I'm doing a PHP site which displays code examples in various languages (C#, PHP, Perl, Ruby, etc.). Are there any PHP functions which add syntax coloring for these and other languages?
If not, I would at least like to find that one built-in PHP function which does syntax coloring for PHP code, can't find it anymore. Thanks.
Why not do the syntax coloration in the client side?
Use prettify.js, its really versatile, Google Code and StackOverflow use it!
Check the test page for the supported languages.
You'd probably be better off formatting it in javascript actually. There are a few mature javascript syntax colors.
highlight.js
google highlighter
prettify
For highlighting PHP use highlight_string(). (This may work OK with other languages as well.)
Edit: This function requires that the string start with the PHP opening tag. What I did on my site to get around this was I passed something like "<?php\n$code\n?>" to the highlight_string() function and then used regex to strip out the starting and ending tags that I had added in. This method has worked pretty well for highlighting C/C++, Scheme, and Java (and PHP that doesn't have the <?php ?> tags.)
As already mentioned Google prettify.js is really good, but if you want to do it on the server in PHP you could try looking at Pear Text Highlighter

Categories