syntaxhighlighter / syntaxhighlighter

SyntaxHighlighter is a fully functional self-contained code syntax highlighter developed in JavaScript.
MIT License
5.33k stars 1.28k forks source link

I can't syntax-highlight php #345

Closed ghost closed 9 years ago

ghost commented 10 years ago

Hi folks, I am willing to show php code within a php file. I have followed all the steps, but for some reason, the code is being parsed as php, and not plain text. The problem is, i can not show my line of php code on the page. i am attaching an image for clarification. screen shot 2014-09-24 at 8 57 26 pm

LaKing commented 10 years ago

My guess is that the php code is executed on the server. To verify this, view the source of the Hello SyntaxHighlighter page on the browser. You will probably see only "some text" in the cdata tags. You could rename index.php to index.html, that will eventually prevent the server to interpret the file.

(I guess you are beginning with web programming. I do not recommend learning PHP, but Javascript and nodeJS instead. )

ghost commented 10 years ago

Thank you.

Yes, i am beginning with web programming. I am very interested in understunding why do you recommend me to learn nodejs, instead PHP. I dont want to waste time learning a languague i will use for short period of time.

I have read in many sites, people defending nodejs, as well as people defending php.

Wordpress and facebook, are both written with php, right? i guess they choose php instead of nodejs for some reason... what do you think.

please, enlighten me :D i want to learn the good way from the begining!

thank you so much for taking the time to answer. i really appreciate it.

2014-10-01 8:57 GMT-03:00 LaKing notifications@github.com:

My guess is that the php code is executed on the server. To verify this, view the source of the Hello SyntaxHighlighter page on the browser. You will probably see only "some text" in the cdata tags.

You could rename index.php to index.html, that will eventually prevent the server to interpret the file as php file.

(I guess you are beginning with web programming. Dont learn PHP, learn Javascript and nodeJS .)

— Reply to this email directly or view it on GitHub https://github.com/alexgorbatchev/syntaxhighlighter/issues/345#issuecomment-57452849 .

http://www.ameba.com.uy/_BRUNO SASTRE__DISEÑADOR WEB_2619 3205 | Río de la Plata 1681 | http://goo.gl/maps/nxqD7bsastre@ameba.com.uy | www.ameba.com.uy https://www.facebook.com/ameba.diseno https://twitter.com/amebaUruguay http://www.linkedin.com/company/ameba_2 http://www.pinterest.com/amebauruguay/

LaKing commented 10 years ago

Facebook and Wordpress are older then NodeJs. They could have been written in ruby maybe. Also, Facebook had to develop a compiler that helps them to run code fast enough, so I wouldn't say its running on pure PHP as it is.

The popularity of PHP is based on history, and it might be working on a level, other languages are better to produce better quality code, faster and easier. A great article describing the problem is: http://eev.ee/blog/2012/04/09/php-a-fractal-of-bad-design/

When I started web programming, I also had this opinion, and started learning PHP. Half world uses PHP, it must be good. I was wrong. I started to write a bigger project, and after a while, I started to hate it. Then I turned to ruby, and realized that ruby is much more advanced, much more modern, but already outdated. I met a few Node applications, and my attention turned to javascript. I feel very comfortable now developing javascript, on client and on server side. Having a single scripting language on your mind is a huge advantage. And I know that there is pecl, and a lot of PHP code out there, but that comes not even close to what npm can do.

Most people defending PHP are those who learned PHP and don't speak anything else. Professional programmers either use java, or javascript, ruby, perl, python, or whatever ...
Programmers should never be afraid of learning a new language, but 90% of the web programmers are too busy with their projects and their commercial existence, and don't have time to change to a new language. As a newcomer to web programming, you don't have that problem, .. so I really recommend you to learn anything else, but not PHP. :)

In general, a new technology is usually better then an ancient technology. You should look around twice, and decide based on your needs.

ghost commented 10 years ago

Laking, Thanks so much for taking the time (again) to write me back, i really appreciate it. I wasn't expecting such a detailed response! Ok, so Facebook and Wordpress are older than NodeJs... that explains everything i guess...

I have skimmed over the article you sent me... i am being convinced that php has a short life. I really liked The Analogy of the carpenters. :) So here i am, learning web programming at my 29's, in a hurry to learn up the faster i can, making my first steps in php, and suddenly, y realize i should be learning NodeJs and not PHP. What should i do?

First of all... i am taking a little course on php on school. Is part of the whole carrer, so i have to finish it. I also work as a junior web designer/developer in a design agency, and we all use wordpress, in fact, the vast majority of blogs, and content managed sites are built in wordpress, and the numbers are growing up every day.

I doubt i could convince my boss to turn to Node... what about Wordpress?

i really want to do the things the right way, but i feel a little trapped under php. Why doesnt Wordpress turn to Node?

Does it make sense to learn both? how difficult could that be?


regarding my issue with syntax highlighter, this is what i want to achieve, is really simple.

I want to make my own mini-site of php notes... I need to have quick access to all the material i am learning, and will be learning... I figured out it would be nice, to have a sidebar, with a list of every function, and every new syntax that i learn of php. When i click on a list item (lets say 'include') i want to go to the 'include-page.php' where i would have everything about include function. I could do this with html, but i would have to copy/paste the sidebar on every page, that's where php was comming hanndy, but, as it turned out, syntaxhiglighter doesnt work on server side....

do you think there's some way to overcame this issue?

LaKing commented 10 years ago

Maybe, while learning PHP, in parallel compare it 'inline' with node. Learn both by doing the same task twice. Or at least, some of them,... Alternatively, you can work at your workplace and, eventually dev your own project in your own time, and choose your language and tools free.

PHP will have a long life - but still, that does not make it good, and eventually you will have a shorter life if you stress about bugs too much.

Wordpres is wordpress, they wont rewrite it. What you can do is to look out for another CMS written in node / javascript, rails, or whatever.. but maybe the best is to brew your own, with express, bootstrap, etc, ...

If you have a boss, who dictates what to write in what language, .. you agree on your work-fee, and If you agree, you agreed. In that case your company is responsible to spend your time on effective coding, and the economic part. Lot of companies are stuck in this circle, .. my guess is that with time other companies based on newer technologies will take over, and re-implement or re-design the sites slowly, one-by one, as customers decide to change/update their sites.

What you want to achieve, .. you can develop it yourself. I don't see a problem technically in the fact, that highlighter is client side. By the way highlight.js - another highlighting implementation has server side npm as well. ;)

If you like, take a look at ep_codepad, it is an IDE I'm developing now, and IMO the functionality you want, is already built in there. (sidebar, cut and paste code, highlighted view, .. etc.) It is under heavy construction, ...