Skip to main content
Inspiring
Jun 27, 2016 2:28 PM UTC
Answered

missing a few html link basics

Hi all,

I seem to be missing a few html link basics. What is the significance of:

starting slash...?

<form action="/mypage.php" method="POST">  like:

I know these can redirect:

dig down..

/myfolder/mypage.php

and up

../myfolder/mypage.php

but now I am seeing a starting slash and a page ???

/mypage.php

or

./mypage.php

instead of just = mypage.php

Q: why use starting ./ or / instead of just the page?

MORE...

and while I am at it... I always use closing php tag like:

<?php

stuff...

?>

... but now I am hearing if there is only php on the page - then it's best to *NOT* use a closing tag?

Q: Why is that?

    This topic is closed to new replies. Start a new post to keep the conversation going.
    Jon Fritz
    Jon FritzCorrect answer
    Community Expert
    Jun 27, 2016 2:45 PM UTC

    The starting slash means "site root relative" which tells the browser to add the site root before the link, so...

    /somelink.html

    ...becomes...

    h t t p ://www.domain.com/somelink.html (spaces added to http keep the forum from turning it into a link)

    ...automatically at the browser level.

    Not sure about the php thing, always heard that as you "can" leave it out.

    3 replies

    Jon Fritz
    Community Expert
    Jon FritzCommunity ExpertCorrect answer
    Community Expert
    Jun 27, 2016 2:45 PM UTC

    The starting slash means "site root relative" which tells the browser to add the site root before the link, so...

    /somelink.html

    ...becomes...

    h t t p ://www.domain.com/somelink.html (spaces added to http keep the forum from turning it into a link)

    ...automatically at the browser level.

    Not sure about the php thing, always heard that as you "can" leave it out.

    Translate
    revdaveAuthor
    Inspiring
    Jun 27, 2016 9:57 PM UTC

    Great - thanks for the help!

    so now I get /somelink.html

    what about with starting period = ./somelink.html ?

    Translate
    David_Powers
    Inspiring
    Jun 27, 2016 10:11 PM UTC

    That means somelink.html is in the same folder (directory).

    Translate