#PHP, 182 bytes#
PHP, 182 bytes
This seemed like a fun activity for my first answer. Comments on my code are welcome.
<?php function s($n){$e=2*$n+1;for($i=0;$i<$e*$e;$i++){$x=$i%$e;$y=floor($i/$e);echo$y==$x?($x==$n?"O":"\\"):($e-1==$x+$y?"/":($y==$n?"-":($x==$n?"|":" ")));echo$x==$e-1?"\n":"";}}?>
Here is the un-golfed code with comments:
<?php
function s($n) {
$e=2*$n+1; //edge length
for($i=0;$i<$e*$e;$i++) {
$x = $i%$e; // current x coordinate
$y = floor($i/$e); // current y coordinate
if ($y==$n&&$x==$n) {
// center of square
echo'O';
}
else if ($y==$n) {
// horizontal line
echo'-';
}
else if ($x==$n) {
// vertical line
echo'|';
}
else if ($y==$x) {
// diagonal line from top-left to bottom right
echo'\\';
}
else if (($y-$n)==($n-$x)) {
// diagonal line from bottom-left to top-right
echo'/';
}
else {
// empty space
echo' ';
}
if ($x==$e-1) {
// add new line for the end of the row
echo"\n";
}
}
}?>
<pre>
<?php s(10); ?>
</pre>
Edited with code by royhowie