How can inline colors in PHP code be replaced with CSS classes for better code organization and maintainability?

Inline colors in PHP code can be replaced with CSS classes for better code organization and maintainability by creating CSS classes that define the colors and applying those classes to the HTML elements instead of using inline styles. This separation of concerns allows for easier maintenance and updates to the styles without having to modify the PHP code.

// Before
echo '<div style="color: red;">Hello, World!</div>';

// After
echo '<div class="red-text">Hello, World!</div>';
```

CSS:
```css
.red-text {
  color: red;
}