echo ' <input type="button" onmouseover="this.style.cursor='pointer'" >
';

How can I use single quote within echo ' ........ '; ?
Above sytax made parse error for single quotes ( this.style.cursor='pointer' ).

    Escape them with a backslash ( \ ) like you would for double quotes.

      Use a slash for a literal single quote.
      echo 'blah blah\'s';

      Same goes for double quotes
      echo "he said \"blah blah's\"";

        Thank you so much. Again please help me.

        echo '
        <a href="login.php?language=$language" onmouseover="this.style.cursor=\'pointer\'"> ';

        I would like to use $language as variable (e.g. language=en-us ). But it works as language=$language.

          If you want to render your variables in your code, you need to use double quotes.

          echo "<a href=\"login.php?language=$language\" onmouseover=\"this.style.cursor='pointer'\">";

            Both of these questions could have been answered by looking at the manual. Looking there would probably be faster than asking here and waiting for an answer.

              Thank you so much for your link. But let me ask another question.

              echo '

              <SCRIPT TYPE="JavaScript">

              var r = new resetimage($src);

              ri.write();

              </SCRIPT> ';

              $src is php variable. How can I pass this $src to javascript fun. I have already tried the following style. But it also doesnt work.

              echo "var r = new resetimage($src);" ;
              echo "ri.write();" ;

                <?php
                // some code here then break off PHP
                ?>
                <SCRIPT TYPE="JavaScript"> 
                
                var r = new resetimage(<?php echo $src;?>); 
                
                ri.write(); 
                
                </SCRIPT> 
                <?php
                // continue your php code here
                ?>

                  Thank you so much for your information although I have already got it.

                  Again many thanks.

                  regards,
                  Mitchell

                    Originally posted by Weedpacket
                    Both of these questions could have been answered by looking at the manual. Looking there would probably be faster than asking here and waiting for an answer.

                    Practically any question could be answered by the manual, so why bother even having this messageboard?

                    Just replace the messageboard with a link to the manual.

                      Hands up who wants to guess how many times someone has asked in these forums how to put a PHP variable into Javascript?

                      (Hint: many of the the threads can be found by searching these forums for the words "PHP" and "Javascript" in the title.)

                      -
                      If you have a question, this really isn't the first place to ask. No, really. The advertisers might not want me to say that, but it's true.

                        I DO admit that I have a little knowledge about php. If anyone have a question after reading some related docs, where should the first place be asked ?

                          If anyone have a question after reading some related docs, where should the first place be asked ?

                          If you cant find the answer after looking for it in the docs, then search the Web and/or this messageboard.

                          Only if you still cannot find the answer, or really do not understand the existing answers, then should you post the question.

                            Write a Reply...