For any prime number p , we provide two classes of linear codes with few weights over a p-ary alphabet. These codes are based on a well-known generic construction (the defining- set method), stemming on a class of monomials and a class of trinomials over finite fields. The considered monomials are Dembowski-Ostrom monomials x p (alpha +1) , for a suitable choice of the exponent alpha , so that, when p > 2 and n not equal 0 (mod 4), these monomials are planar. We study the properties of such monomials in detail for each integer n > 1 and any prime number p . In particular, we show that they are t-to-one, where the parameter t depends on the field Fpn p n and it takes the values 1, , 2 or p +1. Moreover, we give a simple proof of the fact that the functions are delta-uniform with delta E {1, , 4, , p }. This result describes the differential behavior of these monomials for any p and n . For the second class of functions, we consider an affine equivalent trinomial to x p (alpha +1) , namely, x p (alpha +1) + lambda xp(alpha) + lambda p(alpha) x for lambda E F-pn(& lowast;). We prove that these trinomials satisfy certain regularity properties, which are useful for the specification of linear codes with three or four weights that are different than the monomial construction. These families of codes contain projective codes and optimal codes (with respect to the Griesmer bound). Remarkably, they contain infinite families of self-orthogonal and minimal p-ary linear codes for every prime number p . Our findings highlight the utility of studying affine equivalent functions, which is often overlooked in this context. (c) 2024 The Author(s). Published by Elsevier Inc. This is an open access article under the CC BY license (http:// creativecommons .org /licenses /by /4 .0/).