I know one way.
open this page: http://qbnz.com/highlighter/demo.php
the above link is a php syntax shortcut on the net,
(1) copy and paste your php code into the text area with the inscription "Login via text field:"
(2) go to the "Options" selection box below this text area and select "Line Numbers: None"
(3) click "Highlight"! at the bottom of the page
(4) the highlighted php code will be shown
(5) select, copy the highlighted code and paste it into Word. u will see color code in a Word document
those "are detailed steps
hope this helps
source share