• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

missing a few html link basics

Contributor ,
Jun 27, 2016 Jun 27, 2016

Copy link to clipboard

Copied

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?

Views

639

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jun 27, 2016 Jun 27, 2016

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.

Votes

Translate

Translate
Community Expert ,
Jun 27, 2016 Jun 27, 2016

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Jun 27, 2016 Jun 27, 2016

Copy link to clipboard

Copied

Great - thanks for the help!

so now I get /somelink.html

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 27, 2016 Jun 27, 2016

Copy link to clipboard

Copied

LATEST

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines