Viewed   47 times

I have my site on the server

On this server I have two domains: and

I would like to get the current domain using PHP, but if I use $_SERVER['HTTP_HOST'] then it is showing me

instead of: or

How can I get the domain, and not the server name?



Try using this:


Or parse :



Friday, September 9, 2022

I use following wrapper class in my php5.2 apps: Untill php5.3 was released - it saves much my time

Thursday, November 3, 2022

The issue is with the use of default JSON converter. Here are your options:

 1. Default  -  all fields, shallow associations
    a. render blah as JSON

 2. Global deep converter - change all JSON converters to use deep association traversal
    a. grails.converters.json.default.deep = true

 3. Named config marshaller using provided or custom converters
    a. JSON.createNamedConfig('deep'){
        it.registerObjectMarshaller( new DeepDomainClassMarshaller(...) )
    b. JSON.use('deep'){
        render blah as JSON

 4. Custom Class specific closure marshaller 
    a. JSON.registerObjectMarshaller(MyClass){ return map of properties}
    b. render myClassInstance as JSON

 5. Custom controller based closure to generate a map of properties
    a. convert(object){
        return map of properties
    b. render convert(blah) as JSON

You are currently using Option 1, which is default.

The simplest you can do is use Option 2 to set global deep converter, but be aware this effects ALL domain classes in your app. Which means that if you have a large tree of associations culminating in a top level object and you try to convert a list of those top level objects the deep converter will execute all of the queries to fetch all of the associated objects and their associated objects in turn. - You could load an entire database in one shot :) Be careful.

Sunday, December 11, 2022

It will be destructed (unloaded from memory) at the end of the page load, or if you unset all references to it earlier. You will not have to destroy it manually since PHP always cleans up all memory at the end of the script.

In fact, you should never call __destruct yourself. Use unset to unset the reference to an object when you want to destroy it. __destruct will in fact not destroy your object, it's just a function that will get called automatically by PHP just before the destruction so you get a chance to clean up before it's destroyed. You can call __destruct how many times as you want without getting your memory back.

If, however, you've saved the object to a session variable, it will "sleep" rather than be destroyed. See the manual for __sleep. It will still be unloaded from memory (and saved to disk) of course since PHP doesn't hold anything in memory between scripts.

Monday, August 1, 2022

shall provide you current url in rails 4.

You can visit this resource for more info @ How do I get the current absolute URL in Ruby on Rails?

Saturday, September 10, 2022
Only authorized users can answer the search term. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :