seblondres Posted September 11, 2014 Share Posted September 11, 2014 Hi, I'm not sure where to add the <a href= </a> in the code below to make it as an hyperlink? <?php echo "<h1>{$_SERVER['SERVER_NAME']}</h1>"?> Many Thanks, Link to comment Share on other sites More sharing options...
Ingolme Posted September 11, 2014 Share Posted September 11, 2014 There are many ways to do it. echo '<a href="' . $_SERVER['SERVER_NAME'] . '">' . $_SERVER['SERVER_NAME'] . '</a>'; Link to comment Share on other sites More sharing options...
seblondres Posted September 11, 2014 Author Share Posted September 11, 2014 thanks for your help , it works apart that when I click on the link the page is not found because the url contains the domain name twice e.g. mysite.com/mysite.com <?php echo '<h1><a href="' . $_SERVER['SERVER_NAME'] . '">' . $_SERVER['SERVER_NAME'] . '</a></h1>';?> Link to comment Share on other sites More sharing options...
Ingolme Posted September 11, 2014 Share Posted September 11, 2014 <?php echo '<h1><a href="http://' . $_SERVER['SERVER_NAME'] . '">' . $_SERVER['SERVER_NAME'] . '</a></h1>';?> Are you sure you need an <h1> element there? Link to comment Share on other sites More sharing options...
seblondres Posted September 11, 2014 Author Share Posted September 11, 2014 ok works fine now many thanks for your help. I have added the <h1> tag because I can't style it otherwise but that's another issue. Link to comment Share on other sites More sharing options...
Ingolme Posted September 11, 2014 Share Posted September 11, 2014 You can target the <a> element with CSS, change font size, weight, color and anything else. If you use <h1> the wrong way search engines will not rank your page correctly for the right searches. Aside from the <title> element, <h1> is one of the first things Google looks at when indexing a page. Link to comment Share on other sites More sharing options...
seblondres Posted September 11, 2014 Author Share Posted September 11, 2014 ok thanks, I have use css instead of <h1>, all good now. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now