PHP inside the css is it possible?

0

I'm changing the logo of the WordPress link screen. For this I am using PHP to filter the function by swapping the CSS. But since I have several services like this, I need to do it dynamically, that is, use the same code for several sites. Then it will look like this:

function my_f(){
echo '<style type="text/css">
   h1 a{background-image:url( php tem que ser aqui "exemplo: function();" )
   } 
</style>';
}

This is generating a problem because php is seeing this as a string.

    
asked by anonymous 06.07.2017 / 19:42

1 answer

0

You can not execute a function you can get the return of the function:

function funcaoDeExemplo() {
    return 'algo aqui.jpg';
}

function my_f(){
echo '<style type="text/css">
   h1 a{background-image:url(' . funcaoDeExemplo() .  ')
   } 
</style>';
}

If what you want to do PHP on the front-end layer is not possible "directly", understand more about front-end and back-end first:

So the interaction depends on other means or completely change the approach.

    
06.07.2017 / 19:45