FRIHOSTFORUMSSEARCHFAQTOSBLOGSDIRECTORY
You are invited to Log in or Register a Frihost Account!

Variables

 


Ndogg
Code:
$include1 = #include "StdAfx.h"
$include2 = #include "Setup.h"
$include3 = #ifdef WIN32
$include4 = #pragma warning(disable:4305)
$include5 = #endif

echo "Script:<br />";
echo "$include1<br />";
echo "$include2<br />";
<br />
echo "$include3<br />";
echo "$include4<br />";
echo "$include5<br />";


The problem is with the variables and the way its written, dont worry about the fact that its not inbetween anything.

How do I write this?


Last edited by Ndogg on Wed Jul 01, 2009 1:57 am; edited 1 time in total
Marcuzzo
try
Code:
$include1 = "#include \"StdAfx.h\" ";
$include2 = "#include \"Setup.h\" ";
$include3 = "#ifdef WIN32 ";
$include4 = "#pragma warning(disable:4305) ";
$include5 = "#endif" ;
Ndogg
Works, thanks alot!
riccopt
If I were you I wouldn't have add the complete PATH on your post...
Ndogg
Why?
tukun2009manit
Ndogg wrote:
Code:
$include1 = #include "StdAfx.h"
$include2 = #include "Setup.h"
$include3 = #ifdef WIN32
$include4 = #pragma warning(disable:4305)
$include5 = #endif

echo "Script:<br />";
echo "$include1<br />";
echo "$include2<br />";
<br />
echo "$include3<br />";
echo "$include4<br />";
echo "$include5<br />";


The problem is with the variables and the way its written, dont worry about the fact that its not inbetween anything.

How do I write this?


the code is in which language?
rickylau
Obviously in PHP, but I'm wondering why do this way.
For me, I may do in this way
Code:
$include = "#include \"StdAfx.h\"\n";
$include .= "#include \"Setup.h\"\n";
//...
$include .= "#endif\n";

or
Code:
$include = "#include \"StdAfx.h\"\n#include \"Setup.h\"\n...#endif\n";

Then use nl2br () to show as HTML.

Now, I just found in PHP there is another way of defining a string value called heredoc, something like this
Code:
$include = <<<CODE
#include "StdAfx.h"
#include "Setup.h"
...
#endif
CODE;


One more thing, double quote may make browser confused if outputted directly, you should use htmlentities () before you echo the string
blueray
I assume you are building include list only.
Here is another way to do.

Code:

$includes = array(
   '#include "StdAfx.h"',
   '#include "Setup.h"',
   '#ifdef WIN32',
   '#pragma warning(disable:4305)',
   '#endif',
);

echo join('<br />', $includes);

Marcuzzo
there are several ways to make this work... Wink

usualy the most simple is the best.
Related topics

PHP Includes and Variables?
Problem with session variables
Separating contents of MySQL row and put them in variables?
problem adding variables in javascript
using variables

How to make Global Variables with PHP?
Javascript Variables FRIH$ to Debug
Urls into variables
ImageMagick path and variables, GD support?
Catching unused variables

session variables
The matrix online hints and tips
Session variables versus page variables
Variables Seperated strings
An easy way to echo all parts of these variables.

unsetting variables - when to and when not to
Reply to topic    Frihost Forum Index -> Scripting -> Html, CSS and Javascript

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2007 Frihost, forums powered by phpBB.