I want to know the value of $base_url.

I found out that print($base_url) at the end of index.php works, so I tried it inside a costom block and it didn't work. Why?

I then found out that if I write
global $base_url;
it works.

How can this be? The keyword global makes no sense outside a function, but if I start writing

<?php

how can it be that I am already inside a function? How does this all work?
And If I am really inside a function at this point (which would smell *very* strange to me), where can I find the function definition? what parameters are given to that function? when and by what is it called?

Please enlighten me.

Bernd

Comments

ezheidtmann’s picture

When you write code for a PHP page or block, you are inside eval(), which is inside drupal_eval():

http://drupaldocs.org/api/head/function/drupal_eval