Php replace class name

PHP Function to Replace CSS Class Names

The problem is that you’re removing all the whitespace around the class with the \s* patterns in the regexp.

Instead of matching whitespace, use \b to match word boundaries.

 $m[0] = preg_replace("/\bcontainer\b/",'product-description-table',$m[0],1); 

More Answer

  • How to call Private function form static function in PHP class
  • php create global object, load class
  • php call function from another class
  • How return a value from one class function to another class function in PHP
  • Redeclaring class in php file where now generated a function
  • Get name of a class from where the function was called in PHP
  • PHP How to pass an instance of the class in the function of another class?
  • How can I use mysql connection if connection is made in a php class and the function mysqli_real_escape_string is used in a separate functions file?
  • How can I use mysql connection if connection is made in a php class and the function mysqli_real_escape_string is used in a separate functions file?
  • replace cryptoJS with PHP function
  • Changing the values of a php class using a function
  • When Class method same name php function
  • Create function make singleton class PHP
  • css not fully applying to php function
  • HTML class names with php variables
  • HTML class names with php variables
  • Parse css and create key value array of class names and background images
  • Capture instance of PHP class and call an instance function from JS
  • Rename directory names and class names of maagento php files
  • Ajax calling PDO function in PHP class to update a page
  • Php class declaration inside class method with same names and PSR-0 namespaces, error
  • Global variable inside class and function PHP
  • Calling php class function in javascript (ajax)
  • Replace dynamically value of options while passing the output of a php function
  • Obfuscate/Encode/Encrypt PHP System Function Names
  • Send class definition to function in PHP
  • Using PHP how can I find a CSS tag/id/class and replace the style within the curly braces?
  • Is there a way to get the registered function names in php nusoap library?
  • Change css class of loop values in PHP
  • Magento Top Nav: Add CSS class to first category using PHP
  • Replace html tags and pass to function in php
  • How to replace to html code with a php function
  • How to replace to html code with a php function
  • Autosetting Function Names based on Parameter Input in PHP
  • Getting a PHP Project Class and Function search Command to work in TextMate
  • Class or function to make a listview like table in html through php and jquery
  • The String Replace function in PHP is not working for me
  • Set a non-string variable in a function in a class to get in other PHP files class
  • Php OOP use my function in other class without extends
  • Php OOP use my function in other class without extends
  • Replace html tag with class and var php
  • Overriding a function in base class php
  • Error passing multiple parameter to PHP function (Object of class comments could not be converted to string error)
  • PHP function to read directory & collect filenames &subdirectory names into an array?
  • PHP function to read directory & collect filenames &subdirectory names into an array?
  • Integrating two PHP applications which uses same class names, variables names
  • php — if css div class exists in body, add stylesheet to head
  • Having trouble with PHP ob_start callback function in a class
  • php string replace function with more exact results?
  • Is it possible to automatically generate PHP function names from an array of values?

More answer with same ag

  • How to generate a subscription system that expire after a defined amount of time? Drupal 7
  • PDO is importing NULL Values to MySql
  • PayPal Donation — Transaction Details
  • Error with uploading images
  • I want to create a Web Service in PHP to process Paypal transactions
  • Reroute URLs like Facebook and WordPress
  • beginner looking for an explanation about how this php ajax image upload script works
  • PHP: fatal error while using namespaces
  • Does PHP work for disabled HTML tags?
  • How to remove Data between Tags
  • Python Regular Expressions in PHP
  • Timeout problems processing large remote files
  • speeding up MySQL queries in PHP
  • Drupal 7 merging two projects into one, nesting functions problems
  • Restful Get Json from URL by POST method and add to DB?
  • Filter input array for PHP < 5.2
  • PHP mysqli table query gives multiple results that i want to query against another table
  • «Call to a member function send() on strin» error appear when my middleware run on laravel
  • Getting Permission To Write a New File to a Server in PHP
  • EVERY other aspect of my PhP code seems to work, but the Echo statements don’t appear
  • Show ‘free shipping’ button in Magento product grid
  • PHP: Avg Grade by category
  • Trying to get property ‘title’ of non-object Curl PHP
  • Change DIV color background depending on MIN and MAX array values?
  • Expression Engine: Use Category URL Titles In Links — YES / Category URL Indicator
  • How to extracting individual dimensions from $node->content[‘dimensions’] in Drupal’s Ubercart?
  • Magento not using correct DB details
  • PHP- Create a process to read in a tab-delimited file and display the results sorted by a specific column.
  • PHP — Fatal error: Can’t use method return value in write context
  • JS events. Only one of the event handler function is being called?
  • Set array in one php file and access in another php file issue
  • How to change foreach in php?
  • How to call the Last record in an array
  • RecursiveIteratorIterator on multidimensional array with indexed elements
  • Encoding with JQuery AJAX and PHP
  • php array into multidimentional array foreach
  • Catching the returned value
  • Fire PUT request using CURL in PHP
  • PHP Using Doubles Instead of Floats
  • PHP Call to a member function on a non-object -> Classes
  • PHP: Remove useless parts from filename
  • Show success message when deleted (query succesfull)
  • Google email audit API Admin SDK
  • how can I count the likes for posts via my app?
  • User Log in page
  • sending mail with multiple attachment in php
  • Enable a disabled text-field and save modified value
  • In PHP how can I detect when a user is deleting text from an input text field
  • How to replace \r\n with a line break
  • MSSQL returns multiple rows into array, explode into one array per row

Источник

Замена css класса

Замена шрифтов в css
Всем привет подскажите мастера чайнику, как можно прописать в css шрифты так, чтобы первый.

Замена ссылки .css файла
Столкнулся с проблемой. Вообщем ситуация такая: Есть страничка в которой подгружается .css файл.

Замена CSS файлов-стилей
Вопрос глупый, но всё же. Задача: менять стили страницы кликом мыши. Ситуация простая, сам.

Замена слов через CSS
Здравствуйте! Подскажите, возможно ли через CSS провести русификацию сайта mishastik.com? То есть.

Эксперт HTML/CSSЭксперт PHP

script> var wind = window.location.pathname; if(wind=='site.ru/index.php?fon2') { document.body.className = "fon2"; } else { document.body.className="fon1"; } script>

Добавлено через 3 минуты
а хотя, пардон это не пашет

Добавлено через 7 минут
вот так надо — полный путь писать от корня сайта

script> var wind = window.location.pathname; if(wind=='http://site.ru/index.php?fon2') { document.body.className = "fon2"; } else { document.body.className="fon1"; } script>

Добавлено через 6 минут
короче. че то не получается с этим js — не мой день походу, сорри))
вот на пыхе вариант))

 $class = ($_SERVER['REQUEST_URI']=='/index.php?fon2')?"fon2":"fon1"; ?> 

Источник

PHP: Using class_alias to maintain BC while moving/renaming classes

Sometimes you want to rename a class or move it to a different namespace. But as soon as it is used anywhere outside the package, this is breaking backwards compatibility and should not be done lightheartedly.

Luckily there is a way in PHP to have both, the old class and the new class, while deprecating the old one: class_alias() .

How to use class_alias() without messing up class autoloading

Let’s say, the old class is OldClass and we want to rename it to NewClass .

First, we rename the class and move it from OldClass.php to a new file NewClass.php .

Now add the following line below the class in the same file (NewClass.php):

\class_alias(NewClass::class, OldClass::class);

Note: You can use the ::class constant for nonexistent classes, it just resolves the class name to a fully qualified class name (FQN) with the rules explained in Name resolution rules, without actually looking up the class.

Now we still need the file OldClass.php because it is loaded when a the OldClass class is used. There we trigger the autoloader for the NewClass class using class_exists():

\class_exists(NewClass::class);

You might ask: Why not “class_alias” in the old file which then autoloads the new file? The problem is that type hints do not trigger the autoloader. Similar to the ::class constant, type hints are resolved to a class name which is compared to the class name of the passed object, without actually looking for the type hinted class! That’s why it is important to have the alias in place as soon as the real class is loaded.

Otherwise passing a NewClass instance to the following function would fail because “NewClass” != “OldClass” and the alias is not defined yet:

function oldFunction(OldClass $old)

For the same reason it is a bad idea to keep the old class as subclass of the new one! With a class alias, both class names are treated as the same class. If the deprecated class extends the original class, a type hint against the deprecated class in client code will throw an error if an object of the new class is passed. Also it does not work for abstract classes, final classes, interfaces and traits.

Alternative location for “class_alias()”

Redditor mglaman suggested another approach, that works well if the package is loaded via composer: Collect the aliases in a separate file, deprecated.php and include it additionally with composer:

This way you have a nice overview of deprecated code and the new classes don’t contain legacy code.

@deprecated Warning in IDE

It is a good practice to mark deprecated code with the @deprecated docblock annotation. IDEs can recognize those and show a notice if you use deprecated methods or classes. Unfortunately, for alisases this is not possible, but found an IDE friendly workaround:

Add this code after the \class_alias() call:

if (! \class_exists(OldClass::class)) < // essentially this is "if(false)" /** @deprecated this is an alias for NewClass */ class OldClass <>>

Alternatively, you could collect these pseudo classes in a separate file, like “.ide.php”, which you never load

Note: Don’t be confused by the “class_” function names. The technique does not only work for classes, but just as well for interfaces and traits.

Источник

Читайте также:  Java out of memory exception
Оцените статью