In this article, we describe an approach for solving partial differential equations with general boundary conditions imposed on arbitrarily shaped boundaries. A continuous function, the domain parameter, is used to modify the original differential equations such that the equations are solved in the region where a domain parameter takes a specified value while boundary conditions are imposed on the region where the value of the domain parameter varies smoothly across a short distance. The mathematical derivations are straightforward and generically applicable to a wide variety of partial differential equations. To demonstrate the general applicability of the approach, we provide four examples herein: (1) the diffusion equation with both Neumann and Dirichlet boundary conditions; (2) the diffusion equation with both surface diffusion and reaction; (3) the mechanical equilibrium equation; and (4) the equation for phase transformation with the presence of additional boundaries. The solutions for several of these cases are validated against corresponding analytical and semi-analytical solutions. The potential of the approach is demonstrated with five applications: surface-reaction-diffusion kinetics with a complex geometry, Kirkendall-effect-induced deformation, thermal stress in a complex geometry, phase transformations affected by substrate surfaces, and a self-propelled droplet.