Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #5354 > unrolled thread

variable path lose slashs when used in an alert

Started byanver <NOSPAMM@NO.SPAMMS>
First post2012-04-06 17:05 +0200
Last post2012-04-07 13:30 +0200
Articles 3 — 3 participants

Back to article view | Back to comp.lang.php


Contents

  variable path lose slashs when used in an alert anver <NOSPAMM@NO.SPAMMS> - 2012-04-06 17:05 +0200
    Re: variable path lose slashs when used in an alert "J.O. Aho" <user@example.net> - 2012-04-06 17:37 +0200
    Re: variable path lose slashs when used in an alert "M. Strobel" <sorry_no_mail_here@nowhere.dee> - 2012-04-07 13:30 +0200

#5354 — variable path lose slashs when used in an alert

Fromanver <NOSPAMM@NO.SPAMMS>
Date2012-04-06 17:05 +0200
Subjectvariable path lose slashs when used in an alert
Message-ID<17ygkeaa4yhfd$.1eiqrmk8tirx2$.dlg@40tude.net>
variable $temp is a path
C:\www\site\test\folder\img.jpg

if I write 
echo $temp;
ok I have all the path
---------

but if I use same variable in an alert I haven't more the correct path;
haven't the \ slashs

echo"<script type='text/javascript'>";
echo "alert('$temp')";
echo "</script>"; 

I tested also string but is equal
$temp=(string)$temp;


is there a solution?

[toc] | [next] | [standalone]


#5357

From"J.O. Aho" <user@example.net>
Date2012-04-06 17:37 +0200
Message-ID<9u8gt6FvuuU1@mid.individual.net>
In reply to#5354
anver wrote:
> variable $temp is a path
> C:\www\site\test\folder\img.jpg
>
> if I write
> echo $temp;
> ok I have all the path
> ---------
>
> but if I use same variable in an alert I haven't more the correct path;
> haven't the \ slashs
>
> echo"<script type='text/javascript'>";
> echo "alert('$temp')";
> echo "</script>";
>
> I tested also string but is equal
> $temp=(string)$temp;
>
>
> is there a solution?

In most systems and scripting languages, the back slash '\' is an "escape" 
sign, for example \n is treated as new line, \t as tab, and this is what your 
javascript is doing and for a backslash to work, you need to use a double 
backslash '\\'.



-- 

   //Aho

[toc] | [prev] | [next] | [standalone]


#5363

From"M. Strobel" <sorry_no_mail_here@nowhere.dee>
Date2012-04-07 13:30 +0200
Message-ID<9uamqtF23uU1@mid.uni-berlin.de>
In reply to#5354
Am 06.04.2012 17:05, schrieb anver:
> variable $temp is a path
> C:\www\site\test\folder\img.jpg
> 
> if I write 
> echo $temp;
> ok I have all the path
> ---------
> 
> but if I use same variable in an alert I haven't more the correct path;
> haven't the \ slashs
> 
> echo"<script type='text/javascript'>";
> echo "alert('$temp')";
> echo "</script>"; 
> 
> I tested also string but is equal
> $temp=(string)$temp;
> 
> 
> is there a solution?

In addition to what //Aho said, you could use a normal forward slash as path
separator, see
http://us2.php.net/manual/en/ref.filesystem.php#73954

/Str.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.php


csiph-web