Display c++ code in php

Display c++ code in php

I am trying to display the contents of a .cpp file in php. I am loading it using fread when I print it out it comes out formatted incorrectly. How can I keep the format without escaping each character?

What are some common Java pitfalls/gotchas for C++ programmer?


Use C++ class from C#
<?php  echo "<pre><code>"; $filename = "./test.cpp"; $handle = fopen($filename, "r");  if ($handle) {     while (!feof($handle)) {         $buffer = fgets($handle, 4096); // assuming max line len is 4096. 

What's the best way to get started in modern game programming and application programming? [closed]
echo htmlspecialchars($buffer); } fclose($handle); } echo "</code></pre>"; ?>
We need htmlspecialchars function to print it out correctly..
Gently kill a process

About Memory Management in Java and C++

Is there a market amongst programmers for an OID-keyed blob store?


Returning a variable sized array of doubles from C++ to C# - a simpler way?
Assuming you want to look at it in a web browser:.
How to use existing C++ code in .NET (C#)
<pre>     <code>         <?php echo htmlspecialchars(file_get_contents($file)); ?>     </code> </pre> 


print it out between the HTML <pre> & <code> tags..

62 out of 100 based on 37 user ratings 262 reviews