For the Novice Bloggers, syntax or code highlighting is one of the hurdles to cross. But there is an easy way to do this, it takes only 10 seconds if you have your code ready for highlighting.
- Get your code ready to which you want to add highlighting.
- Go to hilite.me
- Paste your Code snippet in the source code field and don't forget to select the language of the code you are using
- Next step is selecting the style you want, I bet you will have a hard time in choosing one as they provide 19 different styles.
- You can preview your highlighted code below, when you are satisfied with the style copy the HTML code.
- Then come back to your blogger post editor, change the editor mode to HTML and paste the HTML code there
- Voila ! You have your code snippet highlighted beautifully.
This is the PHP Code snippet I highlighted, This code helps you in fetching IP Address
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
| function getRealIpAddr()
{
if (!emptyempty($_SERVER['HTTP_CLIENT_IP']))
{
$ip=$_SERVER['HTTP_CLIENT_IP'];
}
elseif (!emptyempty($_SERVER['HTTP_X_FORWARDED_FOR']))
//to check ip is pass from proxy
{
$ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
}
else
{
$ip=$_SERVER['REMOTE_ADDR'];
}
return $ip;
}
|