Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 13 of 13
  1. #1
    Regular Coder Jesper Møller's Avatar
    Join Date
    Jun 2006
    Location
    Denmark, Copenhagen
    Posts
    138
    Thanks
    9
    Thanked 0 Times in 0 Posts

    quotation in echo

    Im making my first small PHP script, wher i have to use quotations in some echo funktion but how do i do it
    like this one > echo "link["$id"]=$count;\n";

    Shud i use " or " around the $id
    And do i simply put it in like ["$id"] or ?

    "True knowledge exists in knowing that you know nothing."

    "Education is learning what you didn't even know you didn't know!"

  • #2
    $object->toCD-R(LP); vinyl-junkie's Avatar
    Join Date
    Jun 2003
    Posts
    3,100
    Thanks
    2
    Thanked 23 Times in 23 Posts
    You can use single quotes inside double quotes, or vice versa. It is customary though to use the first option:

    Code:
    echo "link['$id']=$count;\n";
    Music Around The World - Collecting tips, trade
    and want lists, album reviews, & more
    SNAP to it!

  • #3
    Regular Coder Jesper Møller's Avatar
    Join Date
    Jun 2006
    Location
    Denmark, Copenhagen
    Posts
    138
    Thanks
    9
    Thanked 0 Times in 0 Posts
    Thanks ... But every place i read, it say i shud use double quotations in the script ... so It looks like this

    link["test1"]=0


    So your saying i shall do it like this
    > echo 'link["$id"]=$count;\n';

    ???
    "True knowledge exists in knowing that you know nothing."

    "Education is learning what you didn't even know you didn't know!"

  • #4
    $object->toCD-R(LP); vinyl-junkie's Avatar
    Join Date
    Jun 2003
    Posts
    3,100
    Thanks
    2
    Thanked 23 Times in 23 Posts
    It doesn't matter. Either way is correct syntax. Just do it whichever way makes the most sense to you.
    Music Around The World - Collecting tips, trade
    and want lists, album reviews, & more
    SNAP to it!

  • #5
    Senior Coder
    Join Date
    Sep 2005
    Posts
    1,791
    Thanks
    5
    Thanked 36 Times in 35 Posts
    Variables inside single-quotes won't be parsed though, so either:
    PHP Code:
    $id='test1';
    $count=0;
    echo 
    "link['$id']=$count";
    //link['test1']=0 
    or
    PHP Code:
    $id='test1';
    $count=0;
    echo 
    'link["'.$id.'"]=$count';
    //link["test1"]=0 

  • #6
    Regular Coder Jesper Møller's Avatar
    Join Date
    Jun 2006
    Location
    Denmark, Copenhagen
    Posts
    138
    Thanks
    9
    Thanked 0 Times in 0 Posts
    Thank you
    "True knowledge exists in knowing that you know nothing."

    "Education is learning what you didn't even know you didn't know!"

  • #7
    Regular Coder Jesper Møller's Avatar
    Join Date
    Jun 2006
    Location
    Denmark, Copenhagen
    Posts
    138
    Thanks
    9
    Thanked 0 Times in 0 Posts
    When i change it to
    echo*'link["'.$id.'"]=$count';
    I get a error
    Ellegal character
    And it ends op looking like this link["tutorials"]=$count;\nlink["centerpage1"]=$count;\n
    "True knowledge exists in knowing that you know nothing."

    "Education is learning what you didn't even know you didn't know!"

  • #8
    Senior Coder
    Join Date
    Sep 2005
    Posts
    1,791
    Thanks
    5
    Thanked 36 Times in 35 Posts
    is the * a typo in the post, or actually in your code?
    if the latter, then what are you trying to do with it? (pointers??)

  • #9
    Regular Coder Jesper Møller's Avatar
    Join Date
    Jun 2006
    Location
    Denmark, Copenhagen
    Posts
    138
    Thanks
    9
    Thanked 0 Times in 0 Posts
    Sorry * is a typo

    echo'link["'.$id.'"]=$count';
    "True knowledge exists in knowing that you know nothing."

    "Education is learning what you didn't even know you didn't know!"

  • #10
    Regular Coder Jesper Møller's Avatar
    Join Date
    Jun 2006
    Location
    Denmark, Copenhagen
    Posts
    138
    Thanks
    9
    Thanked 0 Times in 0 Posts
    But think i found out myself

    echo 'link["' . $id . '"]=' . $count . ';'\n;

    Dos that look right
    "True knowledge exists in knowing that you know nothing."

    "Education is learning what you didn't even know you didn't know!"

  • #11
    Senior Coder
    Join Date
    Sep 2005
    Posts
    1,791
    Thanks
    5
    Thanked 36 Times in 35 Posts
    without the \n yeah, what sort of editor are you using that copies them as text? :|
    In my post I took the $id out of the quotes, but completely missed/forgot $count.

  • #12
    Regular Coder Jesper Møller's Avatar
    Join Date
    Jun 2006
    Location
    Denmark, Copenhagen
    Posts
    138
    Thanks
    9
    Thanked 0 Times in 0 Posts
    >"In my post I took the $id out of the quotes, but completely missed/forgot $count."

    That i figured out


    >"without the \n yeah, what sort of editor are you using that copies them as text?"

    Well i use GoLive .. But its not GoLive that puts them ther..
    Its the first time im trying to make a PHP script, so i have lookd at other script to find out how to make it.
    I have found a small hit counter script, that works ok, but it cant display the hits or the total hits of multiple pages, so im trying to make my own script to do that. The script that counts the hit (and other scripts frome the same place) use this

    // What type of server is your website on?
    // 1 = UNIX (Linux), 2 = Windows, 3 = Machintos
    $settings['system']=1;

    if($settings['system'] == 2) {$settings['newline']="\r\n";}
    elseif($settings['system'] == 3) {$settings['newline']="\r";}
    else {$settings['newline']="\n";}

    echo "extcount_link[$id]=$count;\n";

    so i thougt it shud bee ther
    "True knowledge exists in knowing that you know nothing."

    "Education is learning what you didn't even know you didn't know!"

  • #13
    Regular Coder Jesper Møller's Avatar
    Join Date
    Jun 2006
    Location
    Denmark, Copenhagen
    Posts
    138
    Thanks
    9
    Thanked 0 Times in 0 Posts
    Got it to work

    I used
    echo "pcount[\"" . $filename . "\"]=" . $filedata . ";\n";

    with ' it simply print what is in the ' '
    With " it make \n to a line break
    "True knowledge exists in knowing that you know nothing."

    "Education is learning what you didn't even know you didn't know!"


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •